Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;##########################
- ;#UPDATEROTATION
- ;#After changing the x offset
- ;# of the map, we need to update
- ;# the rotation in the fastcopy
- ;# routine.
- ;#Explanation:
- ;#It's a bit confusing i admit,
- ;# if you have any questions about
- ;# this part it'd probably be better
- ;# for now just to ask me personally
- ;# about it.
- ;##########################
- updateRotation:
- ld a,(xOff) ;what is the xOffset?
- and 7 ;we're only interested in the lower three bits (essentially xOff % 8)
- ld hl,gbufMask
- ld e,a
- ld d,0
- add hl,de ;pointer to the rotation mask
- ex af,af' ;save a (swap with shadow register)
- ld a,(hl)
- ld hl,maskLeft
- ld (hl),a
- ld hl,maskRight
- cpl ;xor $FF
- ld (hl),a
- ex af,af'
- ld hl,rotateRight
- cp 4
- jr nc,rotarDer
- ld hl,rotateLeft
- rotarDer:
- and %00000011
- ld e,a
- ld d,0
- add hl,de
- push hl
- ld de,rotLeft
- ldi
- ldi
- ldi
- ldi
- pop hl
- ld de,rotRight
- ldi
- ldi
- ldi
- ldi
- ret
- rotateRight: ;if offset greater than or equal to 4, rotate the gbuf right up to four times
- rrca
- rrca
- rrca
- rrca
- rotateLeft: ;the nops keep it smoother (same delay as rlca)
- nop ; so whether we shift or not, it will take the same amount of cycles
- nop
- nop
- nop
- rlca
- rlca
- rlca
- rlca
- gbufMask:
- .db %11111111 ;0 display all of the first byte, none of the second
- .db %11111110 ;1 after rotating left once, we only want the 7 leftern most bits of byte 1, and rightmost bit of byte 2
- .db %11111100 ;2
- .db %11111000 ;3
- .db %11110000 ;4
- .db %11100000 ;5
- .db %11000000 ;6
- .db %10000000 ;7
- drawGbuf:
- ld a,$80
- out ($10),a ;set row ($80: 0, to $BF:63)
- ld hl,saferam1-14+(14*64)-14 ;
- ;
- xOff = $+1
- ld a,0 ;if xOff > 8, skip the first byte (it's offscreen)
- cp 8
- jr c,$+3
- inc hl
- noSkip:
- yOff = $+1
- ld b,0
- inc b
- ld de,14
- add hl,de
- djnz $-4
- noSkip2:
- ld a,$20 ;$20: col 0, $2E: col 14
- ld c,a
- ld b,64 ;64 filas
- fastCopyAgain:
- inc c ;avanzar a proxima fila
- push bc
- ld de,-(14*64)
- out ($10),a ;actualizar columna
- add hl,de
- ld de,13
- inc hl
- fastCopyLoop:
- add hl,de
- ld a,(hl) ;cargar valor en gbuf a a
- rotLeft:
- .db 0,0,0,0 ;rotate the values we need
- maskLeft = $+1
- and $FF ;necesitamos los valores de la izquierda
- ld c,a
- inc hl
- ld a,(hl) ;el proximo byte que llena el resto del primero
- rotRight:
- .db 0,0,0,0
- maskRight = $+1
- and 0
- or c
- out ($11),a
- djnz fastCopyLoop
- pop bc
- ld a,c
- cp $2B+1
- jr nz,fastCopyAgain
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement