Advertisement
raulgarcia

XY form VMEM CPC

Aug 23rd, 2024
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASM (NASM) 1.17 KB | Source Code | 0 0
  1. _calcula_y::
  2. ;;0b PPLL LRRR RRRR+X XXXX
  3. ;;P = Pagina de memoria.
  4. ;;R = Row (Fila Y [0-24])
  5. ;;L = Line (linea [0-7])
  6. ;;X = coordenada X [0-79]
  7.     ld hl,(_pvmem)    ;;direccion original
  8.     ld de,#0xc000     ;;restamos origen inicio pantalla
  9.     sbc hl,de         ;;guardamos
  10.     ld (_pvmem),hl
  11.     ld a,#0          
  12.  
  13. y_LINE::
  14.   ld a,h      
  15.   and #0b00111000   ;;cogemos los bits
  16.   ld h,a
  17.     rrca            ;;division  por 8
  18.     rrca
  19.     rrca
  20.     ld c,a
  21.   ld hl,(_pvmem)
  22.   ld a,h            ;;quitamos los bits Y
  23.   and #0b00000111
  24.   ld h,a
  25.   ld (_pvmem),hl
  26. y_ROW::
  27. ;;0b 0000 0RRR RRRR 0000
  28.   ld hl,(_pvmem)
  29.  loop_h:
  30.     ld a,h
  31.     or a
  32.       jr z,fin_h
  33.  loop_l:
  34.     ld a,l
  35.     sub #0x50
  36.     ld l,a
  37.     ld a,h
  38.     sbc a,#0
  39.     ld h,a
  40.     ld a,(y)
  41.     inc a
  42.     ld (y),a
  43.   jr loop_h
  44. fin_h:
  45.   ld a,l
  46.   sub #0x50
  47.     jr c,calcula_x
  48.   jr loop_l
  49. calcula_x::
  50.   ld a,(y)  ;;ultima ROW
  51.   rlca      ;;multiplicamos por 8
  52.   rlca
  53.   rlca
  54.   add c     ;;y sumamos
  55.   ld c,a    ;;carga en C la posicion Y
  56.   ;;0B 0000 0000 0001 1111
  57.   ld a,l
  58.   and #0b00011111
  59.   ld b,a
  60. fin_l:
  61. jr .
  62. ret
  63. y:: .db 0
  64. y_l:: .db 0
  65. x:: .db 0
  66. _pvmem:: .dw 0xdead
  67.  
Tags: asm z80
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement