NightFox

MSX Pages 0 1 2 Test

Apr 23rd, 2020
1,865
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. FUNCION_MEMORY_GET_RAM_PAGES012_NO_MAPPER:
  2.  
  3.     ld hl, $0000        ; Direccion inicial de la pagina
  4.     ld [(NGN_RAM_BUFFER + MEMORY_PAGE_ADDR)], hl
  5.     ld b, 3             ; Paginas del 0 al 3
  6.  
  7.     @@CHECK_PAGES_LOOP:
  8.  
  9.         push bc         ; Preserva los contadores del bucle
  10.  
  11.         di              ; Deshabilita las interrupciones
  12.  
  13.         ; Paso 1, lee 1 byte
  14.         ld a, [(NGN_RAM_BUFFER + MEMORY_SLOT_ID)]       ; ID de slot
  15.         ld hl, [(NGN_RAM_BUFFER + MEMORY_PAGE_ADDR)]    ; Direccion de la pagina
  16.         call $000C      ; Lee un byte del slot con la ID en A de la direccion HL (RDSLT)
  17.         ld b, a         ; Respaldo del byte leido
  18.         cpl             ; Invierte los bits
  19.  
  20.         ; Paso 2, escribelo invertido
  21.         ld e, a         ; Byte a escribir
  22.         ld c, a
  23.         ld a, [(NGN_RAM_BUFFER + MEMORY_SLOT_ID)]       ; ID de slot
  24.         ld hl, [(NGN_RAM_BUFFER + MEMORY_PAGE_ADDR)]    ; Direccion de la pagina
  25.         push bc
  26.         call $0014      ; Escribe un byte (E) en el slot con la ID en A en la direccion HL (WRSLT)
  27.  
  28.         ; Paso 3, vuelvelo a leer y compara si es el mismo que has escrito
  29.         ld a, [(NGN_RAM_BUFFER + MEMORY_SLOT_ID)]       ; ID de slot
  30.         ld hl, [(NGN_RAM_BUFFER + MEMORY_PAGE_ADDR)]    ; Direccion de la pagina
  31.         call $000C      ; Lee un byte del slot con la ID en A de la direccion HL (RDSLT)
  32.         pop bc
  33.         cp c                        ; Son iguales ?
  34.         jr nz, @@NOT_RAM            ; No lo son, es ROM
  35.  
  36.         ; Paso 4, restaua el byte original en su sitio
  37.         ld e, b         ; Byte a escribir (restaura el original)
  38.         ld a, [(NGN_RAM_BUFFER + MEMORY_SLOT_ID)]       ; ID de slot
  39.         ld hl, [(NGN_RAM_BUFFER + MEMORY_PAGE_ADDR)]    ; Direccion de la pagina
  40.         call $0014      ; Escribe un byte (E) en el slot con la ID en A en la direccion HL (WRSLT)
  41.  
  42.         ; Paso 5, Suma 16kb de esta pagina
  43.         call FUNCTION_MEMORY_COUNTER_ADD_16KB
  44.  
  45.         @@NOT_RAM:
  46.  
  47.         ei              ; Habilita las interrupciones
  48.  
  49.         pop bc          ; Restaura el contador del bucle
  50.  
  51.         ld hl, [(NGN_RAM_BUFFER + MEMORY_PAGE_ADDR)]
  52.         ld de, $4000        ; Siguiente pagina
  53.         add hl, de
  54.         ld [(NGN_RAM_BUFFER + MEMORY_PAGE_ADDR)], hl
  55.        
  56.         djnz @@CHECK_PAGES_LOOP
  57.  
  58.     ; Fin de la funcion
  59.     ret
Advertisement
Add Comment
Please, Sign In to add comment