Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;LCD driving routines for all-purpose goodness. Includes very specific
- ;HUD display routines, since they're drawn directly to the LCD.
- ;
- _drawlcd.z80:
- ;Cycle 1 menu mode LCD update
- FullScreenLCD1:
- ld de,$55AA
- jp FSLCDCO
- ;Cycle 2 menu mode LCD update
- FullScreenLCD2:
- ld de,$AA55
- ;
- FSLCDCO:
- ld (itemp1),sp
- ld hl,$8400+((12*64)-1)
- ld c,$20
- FSLCDLP:
- ld b,32 ;62
- ld a,c ;66
- out ($10),a ;11
- ld sp,-(12*64)+1 ;21
- add hl,sp ;32
- nop
- FSLCDIN: ;
- ld a,(hl) ; .42
- and e ; .46
- res 2,h ; .54
- or (hl) ; .61
- set 2,h ; .69
- out ($11),a ;11
- ld sp,12 ;21
- add hl,sp ;32
- ld a,(hl) ;39
- and d ;43
- res 2,h ;51
- or (hl) ;58
- set 2,h ;66
- out ($11),a ;11
- add hl,sp ;22
- djnz FSLCDIN ;35*
- inc c ;34
- ld a,c ;38
- cp $20+12 ;45
- jp nz,FSLCDLP ;55
- ld sp,(itemp1) ;75
- ret ;86
- ;
- ;
- ;
- ;
- GameScreenLCD1:
- ld a,$80
- out (10h),a ;11
- ld a,$20 ;7 28
- ld c,a ;4 32
- ld hl,$81FF ;10 42
- nop ;4 46
- GFC2L1: ;++ ++
- ld de,-511 ;10
- add hl,de ;11
- out (10h),a ;11 11
- ld b,32 ;07 18
- ld de,8 ;10 21
- nop ;04 25 waste
- GFC2L2: ;
- set 2,h ;08 . 32
- ld a,(hl) ;07 . 39
- res 2,h ;08 . 47
- and %01010101 ;07 . 54
- or (hl) ;07 . 61
- nop ;04 66 65 waste
- out (11h),a ;11 11
- set 3,L ;08 19 ;cheapass addition because address is page aligned
- set 2,h ;08 27
- ld a,(hl) ;07 34
- res 2,h ;08 42
- and %10101010 ;07 49
- or (hl) ;07 56
- add hl,de ;11 67
- out (11h),a ;11 11
- djnz GFC2L2 ;13 24/19
- inc c ;4 23
- ld a,c ;4 27
- bit 3,a ;8 35
- jp z,GFC2L1 ;10 45
- ret
- ;
- GameScreenLCD2:
- ld a,$20
- ld c,a
- ld hl,$81FF
- GFC3L1:
- ld de,-511 ;10
- add hl,de ;11
- out (10h),a ;11 11
- ld b,32 ;07 18
- ld de,8 ;10 21
- nop ;04 25 waste
- GFC3L2: ;
- set 2,h ;08 . 32
- ld a,(hl) ;07 . 39
- res 2,h ;08 . 47
- and %10101010 ;07 . 54
- or (hl) ;07 . 61
- nop ;04 66 65 waste
- out (11h),a ;11 11
- set 3,L ;08 19 ;cheapass addition because address is page aligned
- set 2,h ;08 27
- ld a,(hl) ;07 34
- res 2,h ;08 42
- and %01010101 ;07 49
- or (hl) ;07 56
- add hl,de ;11 67
- out (11h),a ;11 11
- djnz GFC3L2 ;13 24/19
- inc c ;4 23
- ld a,c ;4 27
- bit 3,a ;8 35
- jp z,GFC3L1 ;10 45
- ret
- ;-----------------------------------------------------------------------------
- ;-----------------------------------------------------------------------------
- ;-----------------------------------------------------------------------------
- ;Routines after here should relate to the scoreboard routine. Sure, they take
- ;up a ton of space and have much stuff hardcoded in, but they're fast and
- ;so totally worth it. The right 1/3 of the screen isn't buffered anywhere. Nor
- ;will it ever be.
- DrawScoreboard:
- ;######################################### FAR LEFT SIDE (LIVES, BOMBS, POWER)
- ld a,(keyread)
- bit 4,a ;Y= KEY
- jr nz,$+6
- pop hl ;debugging. Removing stack location
- jp ExitBattleEngine
- ld a,255
- ld (charlives),a ;debugging, maxing out lives for display routine
- ld (charcurbombs),a
- ;##### END DEBUGGING SECTION###
- ld (itemp4),sp ;safety is a relative thing. Hope EI wasn't executed.
- xor a
- dec a
- ld ($8103),a ;bar.
- xor a
- ld c,a ;safety timing. Also want spare zero to keep with other time.
- inc c ;.. Incrementing for eventual decrement below for timing.
- ld a,$80 ;.. @@ Setting cursor row to top of the screen. For safety.
- out ($10),a ;11 >>> INTERLACING KEYBOARD READING ROUTINE WITH SCREENDRAW
- ld a,$FF ;18
- inc hl \ dec hl ;30 Timed for safety.
- out (1),a ;41 D-pad and del/mode/2nd/y= keygroups
- ld a,$BE ;48 7 6 5 4 3 2 1 0
- out (1),a ;59 del mode 2nd y= up right left down
- ld a,$20+11 ;66 @@ Far right column to load
- out ($10),a ;11
- in a,(1) ;22 Getting the keypress results back
- ld (keyread),a ;35 And loading the key value so the rest of the app can see
- cpl ;39 Inverting keyread for logic benefit
- ld b,a ;43 B = Key read
- ld hl,mdanmaku ;53
- ld c,(hl) ;60
- ld a,%00000000 ;67 Timed for safety
- out ($11),a ;11 @@ PLUS SIGN (1/8)
- ld a,b ;15
- ld b,%11110000 ;22 Negate movement mask. Timed for consistency.
- bit isdying,c ;30 Checking to see if movement is to be negated.
- jr z,$+3 ;42/37
- ; and b ; 41
- nop
- ld b,a ;46/45 B = Keycode
- rlca ;50/49 isfocused=b1,mode=b6. 3 rotate lefts.
- rlca ;54/53
- rlca ;58/57
- ld e,a ;62/61
- ld a,%00011000 ;69/68
- out ($11),a ;11 @@ PLUS SIGN (2/8)
- ld a,c ;15 Flags!
- xor e ;19 Current keypress thing.
- and %11111101 ;26 Making only the focused flag stick
- xor e ;30 Stuck.
- ld (hl),a ;37 Next up: Movement, then address calculations.
- ld de,(chary) ;57 DE= character positions
- ld a,%00011000 ;64 @@ PLUS SIGN (3/8)
- nop ;68 Timed for safety
- out ($11),a ;11 >>> INTERLACING CHARACTER MOVEMENT WITH SCREENDRAW
- ld hl,chardu ;21 HL= pointer to ofset thinger.
- ld a,(mdanmaku) ;34 Pulling for isfocused flag 1
- rrca ;38 Move to bit 0 position
- and 1 ;45 isolate that bit
- add a,L ;49 and then increment chardu if needed to chardf
- ld L,a ;53 Autoset movement delta to correct address dpn of focused
- ld a,%01111110 ;60 @@ PLUS SIGN (4/8)
- ld sp,hl ;66 Timed for safety. SP is junk anyway.
- out ($11),a ;11
- ld a,b ;15 Loading in key read
- and %00001001 ;22 Processing up/down events. Bits will be unset if pushed
- jp z,LCDD01 ;32 Jump past a load of bull and add zero to the final tally
- rrca ;36 If carry, then negate movement delta.
- ld a,(hl) ;43 But first load that delta in! (does not affect flags)
- jr c,$+4 ;55/50
- neg ; /58
- LCDR01: ld c,a ;59/62 C = DY saved
- ld a,%01111110 ;66/69 @@ PLUS SIGN (5/8)
- out ($11),a ;11
- ld a,b ;15 Loading in key read
- and %00000110 ;22 Processing right/left events
- jp z,LCDD02 ;32 Jump past if zero. Then add it later on.
- add a,%11111100 ;39 If right (neg), carry will result.
- ld a,(hl) ;46
- jr c,$+4 ;58/53
- neg ; /61 DISCARD HL
- LCDR02: ld L,a ;62/65 L = DX saved
- ld a,%00011000 ;69/72 @@ PLUS SIGN (6/8)
- out ($11),a ;11
- ld h,(56*4)+1 ;15 H = boundary test condition
- ld a,e ;19 CurY
- add a,c ;23 CurY+DY
- cp h ;27 Check boundary. If no carry, exceed boundaries.
- jr c,$+3 ;39/34
- sub c ; /38 CurY-DY for case reversion. DISCARD C
- ld e,a ;43/42 E = New CharY
- ld a,d ;47/46 CurX
- add a,L ;51/50 CurX+DX
- inc bc ;57/56 Timed for safety.
- ld c,a ;61/60 C = New CharY TEMP SAVED
- ld a,%00011000 ;68/67 @@ PLUS SIGN (7/8)
- out ($11),a ;11
- ld a,c ;15 CurX
- cp h ;19 Check boundary
- jr c,$+3 ;31/26 If no carry, exceeded boundaries
- sub L ; /30 CurX-DX for case reversion. DISCARD L
- ld d,a ;35/34 D = New CharX
- ld (chary),de ;55/54 Save new CharX/CharY.
- xor a ;59/58
- ex de,hl ;63/62 HL= xxxxxx00 yyyyyy00
- ld c,a ;67/66 @@ PLUS SIGN (8/8)
- out ($11),a ;11 >>> INTERLACING CHARACTER SPRITE DRAW WITH SCREENDRAW
- ld b,h ;15 B = xxxxxx00
- add hl,hl ;26 HL= x xxxxx00y yyyyy000
- ld a,h ;30 A = x xxxxx00y
- rla ;34 A = x xxxx00yx
- rla ;38 A = x xxx00yxx
- rla ;42 A = x xx00yxxx
- xor L ;46
- and %00000111 ;53 High bits of L, low bits of A.
- xor L ;57
- ld L,a ;61 L of HL completed.
- ld a,%00000000 ;68 @@ PRETICK SPACER (0/8)
- out ($11),a ;11
- ld a,(charlives) ;24 TICKING BAR PRELOADER
- exx ;28 Move to SHADOW registers
- ld e,a ;32 Shadow E = counter
- ld bc,$3C11 ;42 Shadow B = Tickmark , Shadow C = Output port number
- or a ;46 Making sure counter ins't already zero.
- jr nz,$+3 ;58/53 Otherwise, zero out the tickmarker.
- ld b,e ; /57
- ld d,0 ;65/64 Clearing out D for forced zero when convenient.
- nop ;69/68 Timed for safety
- out (c),b ;12 @@ TICK MARK (1/8)
- exx ;15 Move to REGULAR registers
- ld a,(mdanmaku) ;27 Getting danmaku flags directly. Want isfocused [1]
- rlca ;31 Moving to bit 2 for $0400 adder
- cpl ;-- RE-TIME LATER.
- or %10000000 ;38 Putting high bit in for $8(4|0)00
- and %10000100 ;45 And isolating those flags
- xor h ;49
- and %11111110 ;56 High bits of A, low bit of H [y]
- xor h ;60
- ld h,a ;64 Completed H of HL. HL now points to screen buffer.
- xor a ;68 @@ BLANK SPACE (1/8)
- out ($11),a ;11
- ld a,b ;15 xxxxxx00
- rrca \ rrca ;23 00xxxxxx
- and %00000111 ;30 00000xxx
- ld e,a ;34 low byte to DE [E] sprite mask made. Using BOX for...
- ld d,$40 ;41 DE = hitbox mask
- ld a,(de) ;48
- exx \ dec e ;54
- jp nz,$+4 ;66
- ld b,e ;70
- out (c),b ;12 @@ TICK MARK (2/8)
- exx ;16
- ld c,a ;20
- ld b,e ;-- POS. Not going to retime.
- set 3,e ;28 get to sprite masker
- ld a,(de) ;35 get mask
- ld e,a ;39 E=mask (right side)
- and c ;43 right side hitbox
- ld d,a ;47 D=hitbox (right side)
- ld a,e ;51
- cpl ;55
- and c ;59 left side hitbox
- ld c,a ;63 C=hitbox (left side)
- xor a ;67
- out ($11),a ;11 @@ BLANK SPACE (2/8)
- ld sp,8*3 ;21 To center of sprite for hitbox checking
- add hl,sp ;32 Bringing to address.
- ld e,-1 ;39
- ld a,(hl) ;46
- nop ;50 Timed for safety
- exx \ dec e ;58
- jr nz,$+3 ;70/69
- ld b,e ;70/69
- out (c),b ;12 @@ TICK MARK (3/8)
- exx ;16
- ld sp,7 ;26 More preparations.
- ld (itemp1),hl ;42 Location for hitbox. We're only testing.
- res 2,h ;50 the black part of the buffer.
- and c ;54
- add a,e ;58 If anything is result, collide (carry)
- rl b ;66 0000xxxr
- xor a ;70
- out ($11),a ;11 @@ BLANK SPACE (3/8)
- inc HL ;15+2
- ld a,(hl) ;22
- and d ;26
- add a,e ;30
- rl b ;38
- add hl,sp ;49
- exx \ dec e ;57
- jr nz,$+3 ;69/64
- ld b,e ;69/68
- out (c),b ;12 @@ TICK MARK (4/8)
- exx ;16
- ld a,(hl) ;23
- and c ;27
- add a,e ;31
- rl b ;39 00xxxrrr
- inc HL ;43+2
- ld a,(hl) ;50
- and d ;54
- add a,e ;58
- rl b ;66 Finished getting four flags for possible collisions.
- xor a ;70
- out ($11),a ;11 @@ BLANK SPACE (4/8)
- ld hl,(itemp1) ;27 Restoring buffer address so I can draw the hitbox
- ld a,(hl) ;34 Now drawing the hitbox.
- or c ;38
- ld (hl),a ;45
- inc HL ;49+2
- exx \ dec e ;57
- jr nz,$+3 ;69/68
- ld b,e ;69/68
- out (c),b ;12 @@ TICK MARK (5/8)
- exx ;16
- ld a,(hl) ;23
- or d ;27
- ld (hl),a ;34
- add hl,sp ;45
- ld a,(hl) ;52
- or c ;56
- ld (hl),a ;60
- inc HL ;64+2
- xor a ;68 @@ BLANK SPACE (5/8)
- out ($11),a ;11
- ld a,(hl) ;18
- or d ;22
- ld (hl),a ;29
- ld sp,-(36-3) ;39
- add hl,sp ;50 Back to the original address.
- exx \ dec e ;58
- jr nz,$+3 ;70/65
- ld b,e ;70/69
- out (c),b ;12 @@ TICK MARK (6/8)
- exx ;16
- ld a,b ;20 0xxxrrrr
- and %00001111 ;27 checking to see if there's any collisions
- add a,e ;31 boiling down to a single flag
- rla ;35 and we have that single flag
- and 1 ;42
- ld c,a ;46 save it.
- ld sp,7 ;56 Preparing SP for sprite run a bit later. Timed for safety
- nop ;60
- ld a,%00000000 ;67 Also timed for safety
- out ($11),a ;11 @@ BLANK SPACE (6/8)
- ld a,(mdanmaku) ;24 Flags to go by.
- and %00010100 ;31 Get isrecovering and isbombing
- add a,e ;35 Uh huh.
- ccf ;39 So 0=IsInvincible. Used to block collision flag
- and c ;43
- ld c,a ;48 b0 is flag we need to merge with
- exx \ dec e ;56
- jr nz,$+3 ;68/67
- ld b,e ;68/67
- out (c),b ;12 @@ TICK MARK (7/8)
- exx ;16
- ld a,c ;20 need to move to bit 3. At bit 0 atm.
- rlca ;24 b1
- rlca ;28 b2
- rlca ;32 b3
- ld c,a ;36 Saving this back to C so flag can be loaded directly
- ld a,(mdanmaku) ;49 Loading flags directly
- or c ;53 May only set isdying if it is the case.
- ld (mdanmaku),a ;66
- xor a ;70
- out ($11),a ;11 @@ BLANK SPACE (7/8)
- or c ;15 A=0. Check if collision happened
- jp z,$+9 ;25 Jump if no collision
- ld a,(charbolad) ;not worrying about overages here. Happens so rarely.
- ld (charcurbolad),a
- ld a,h ;29
- xor %00000100 ;36 toggling buffer for sprite drawing.
- ld h,a ;40
- ld a,b ;44 0xxxrrrr
- rrca ;48 --xxx---
- exx \ dec e ;56
- jr nz,$+3 ;68/67
- ld b,e ;68/67
- out (c),b ;12 @@ TICK MARK (8/8)
- exx ;16
- and %00111000 ;23
- ld b,a ;27 --xxx---
- rrca ;31 ---xxx--
- rrca ;35 ----xxx-
- rrca ;39 -----xxx
- add a,8 ;46 To address of spritemask
- ld e,a ;50
- ld d,$40 ;57 complete address retrieved
- ld a,(de) ;61
- ld c,a ;65
- exx ;69
- out (c),d ;12 @@ BLANK SPACE (8/8)
- exx ;16
- ld e,b ;20 Moving sprite offset to low byte DE for new address
- cpl ;24 Negating flag and moving that mess off to B
- ld b,a ;28 Inverses flag for other sprite half
- ld d,$87 ;35 Address to sprite is now complete.
- exx ;39
- ld a,(charcurbombs) ;52
- ld e,a ;56 Shadow E = counter
- ld bc,$3C11 ;66 Shadow B = Tickmark , Shadow C = Output port number
- out (c),d ;12 @@ BOMB SPRITE (1/8)
- or a ;16
- jr nz,$+3 ;23
- ld b,e ;27
- exx ;31
- bit isrecovering,(iy+danmakuflags) ;51
- ld a,%01011100 ;58 @@ BOMB SPRITE (2/8) byte prepare
- jp z,$+16 ;68
- out ($11),a ;-- 2/8 byte write
- ld a,(gametimer1) ;--
- and %00010000 ;--
- jp z,DSBNOSPRT ;--
- jp $+5 ;--
- out ($11),a ;11 2/8 byte write (no, this is not a typo)
- ld a,(de) ;18 @@ SPRITE CYCLE (1/8), sprite
- or (hl) ;25 Bring in screenbuf
- and b ;29 Zeroes where screenbuf stays.
- or (hl) ;36 Bring back sprite parts.
- ld (hl),a ;43
- inc HL ;47+2
- ld a,(de) ;54
- exx ;58
- ld L,%01111110 ;65
- nop ;69
- out (c),L ;12 @@ BOMB SPRITE (3/8)
- exx ;16
- or (hl) ;23
- and c ;27
- or (hl) ;34
- ld (hl),a ;41
- add hl,sp ;52
- inc e ;56
- nop ;60
- ld a,%01110110 ;67
- out ($11),a ;11 @@ BOMB SPRITE (4/8)
- ld a,(de) ;18 @@ SPRITE CYCLE (2/8), sprite
- or (hl) ;25 Bring in screenbuf
- and b ;29 Zeroes where screenbuf stays.
- or (hl) ;36 Bring back sprite parts.
- ld (hl),a ;43
- inc HL ;47+2
- ld a,(de) ;54
- exx ;58
- ld L,%01110110 ;65
- nop ;69
- out (c),L ;12 @@ BOMB SPRITE (5/8)
- exx ;16
- or (hl) ;23
- and c ;27
- or (hl) ;34
- ld (hl),a ;41
- add hl,sp ;52
- inc e ;56
- nop ;60
- ld a,%01111110 ;67
- out ($11),a ;11 @@ BOMB SPRITE (6/8)
- ld a,(de) ;18 @@ SPRITE CYCLE (3/8), sprite
- or (hl) ;25 Bring in screenbuf
- and b ;29 Zeroes where screenbuf stays.
- or (hl) ;36 Bring back sprite parts.
- ld (hl),a ;43
- inc HL ;47+2
- ld a,(de) ;54
- exx ;58
- ld L,%01011100 ;65
- nop ;69
- out (c),L ;12 @@ BOMB SPRITE (7/8)
- exx ;16
- or (hl) ;23
- and c ;27
- or (hl) ;34
- ld (hl),a ;41
- add hl,sp ;52
- inc e ;56
- nop ;60
- ld a,%00000000 ;67
- out ($11),a ;11 @@ BOMB SPRITE (8/8)
- ;Starting bomb ticker section
- ld a,(de) ;18 @@ SPRITE CYCLE (4/8), sprite
- or (hl) ;25 Bring in screenbuf
- and b ;29 Zeroes where screenbuf stays.
- or (hl) ;36 Bring back sprite parts.
- ld (hl),a ;43
- inc HL ;47+2
- ld a,(de) ;54
- or (hl) ;61
- and c ;65
- exx ;69
- out (c),d ;12 @@ BLANK SPACE (0/8)
- exx ;16
- or (hl) ;23
- ld (hl),a ;30
- add hl,sp ;41
- inc e ;45
- exx \ dec e ;53
- jr nz,$+3 ;65/60
- ld b,e ; /64
- nop ;69/68
- out (c),b ;12 @@ TICK MARK (1/8)
- exx ;16
- ld a,(de) ;23 @@ SPRITE CYCLE (5/8), sprite
- or (hl) ;30 Bring in screenbuf
- and b ;34 Zeroes where screenbuf stays.
- or (hl) ;41 Bring back sprite parts.
- ld (hl),a ;48
- inc HL ;52+2
- ld a,(de) ;59
- or (hl) ;66
- and c ;70
- exx ;74
- out (c),d ;12 @@ BLANK SPACE (1/8)
- exx ;16
- or (hl) ;23
- ld (hl),a ;30
- add hl,sp ;41
- inc e ;45
- exx \ dec e ;53
- jr nz,$+3 ;65/60
- ld b,e ; /64
- nop ;69/68
- out (c),b ;12 @@ TICK MARK (2/8)
- exx ;16
- ld a,(de) ;23 @@ SPRITE CYCLE (6/8), sprite
- or (hl) ;30 Bring in screenbuf
- and b ;34 Zeroes where screenbuf stays.
- or (hl) ;41 Bring back sprite parts.
- ld (hl),a ;48
- inc HL ;52+2
- ld a,(de) ;59
- or (hl) ;66
- and c ;70
- exx ;74
- out (c),d ;12 @@ BLANK SPACE (2/8)
- exx ;16
- or (hl) ;23
- ld (hl),a ;30
- add hl,sp ;41
- inc e ;45
- exx \ dec e ;53
- jr nz,$+3 ;65/60
- ld b,e ; /64
- nop ;69/68
- out (c),b ;12 @@ TICK MARK (3/8)
- exx ;16
- ld a,(de) ;23 @@ SPRITE CYCLE (7/8), sprite
- or (hl) ;30 Bring in screenbuf
- and b ;34 Zeroes where screenbuf stays.
- or (hl) ;41 Bring back sprite parts.
- ld (hl),a ;48
- inc HL ;52+2
- ld a,(de) ;59
- or (hl) ;66
- and c ;70
- exx ;74
- out (c),d ;12 @@ BLANK SPACE (3/8)
- exx ;16
- or (hl) ;23
- ld (hl),a ;30
- add hl,sp ;41
- inc e ;45
- exx \ dec e ;53
- jr nz,$+3 ;65/60
- ld b,e ; /64
- nop ;69/68
- out (c),b ;12 @@ TICK MARK (4/8)
- exx ;16
- ld a,(de) ;23 @@ SPRITE CYCLE (8/8), sprite
- or (hl) ;30 Bring in screenbuf
- and b ;34 Zeroes where screenbuf stays.
- or (hl) ;41 Bring back sprite parts.
- ld (hl),a ;48
- inc HL ;52+2
- ld a,(de) ;59
- or (hl) ;66
- and c ;70
- exx ;74
- out (c),d ;12 @@ BLANK SPACE (4/8)
- exx ;16
- or (hl) ;23
- ld (hl),a ;30
- add hl,sp ;41
- inc e ;45
- exx \ dec e ;53
- jr nz,$+3 ;65/60
- ld b,e ; /64
- nop ;69/68
- out (c),b ;12 @@ TICK MARK (5/8)
- exx ;16
- pop de ;26
- DSBNOSPRTR: ;Returning from no sprite routine. Riiight.
- ld b,3 ;
- pop de ;39
- pop de ;49
- or (hl) ;56
- inc de ;62
- exx ;66
- out (c),d ;12 blank space
- exx ;16
- pop de ;26
- pop de ;36
- or (hl) ;43
- nop ;47
- exx \ dec e ;55
- jr nz,$+3 ;67/62
- ld b,e ; /66
- out (c),b ;12 @@ TICK MARK (5/8)
- exx ;16
- djnz DSBNOSPRTR+2 ;29/24
- pop de ;34 waste
- ld sp,(itemp4) ;54
- nop ;58
- nop ;62
- xor a ;66
- out ($11),a ;11
- ld hl,DSBswdspt ;21
- ld b,7 ;29
- call DSBDRAWSP ;22 -->45+
- ld a,(charpower) ;35
- call DSBDRAWNM ; -->61
- xor a
- out ($11),a ;11
- ld hl,DSBkilspr-1 ;27
- ld bc,(curkills) ;47
- ld a,$20+10 ;54
- ld b,7 ;61
- inc hl ;67
- out ($10),a ;11
- nop \ nop ;## Not timed. Something wonky is going on and timings out.
- call DSBDRAWSPB ;re-timed.
- nop \ nop ;## Not timed. Something wonky is going on and timings out.
- inc c ;due to effect in the DSBDRAWSP(B) routine
- ld a,c
- call DSBDRAWNM
- ld hl,DSBscrspr
- ld b,6 ;displaying only the first 6 bytes of 11. For accelerations
- call DSBDRAWSP ;22
- ld a,(mgameset) ;35
- bit 4,a ;43 settings yes.
- jp nz,DSBDHEXSC ;53 jump to hex score displayer. Padding digits please!
- ld a,%01111000 ;60 score sprite cycle 07
- inc hl ;66 timed for safety
- out ($11),a ;11
- ld (itemp1),sp ;31
- ld sp,billiontab ;41
- ld ix,(curscore+0) ;61
- ld a,%00000100 ;68 score sprite cycle 08
- out ($11),a ;11
- ld hl,(curscore+2) ;27
- ; ld hl,(scorefilebase) ;debug information to keep the score going up
- ; inc hl
- ;; inc hl
- ; ld c,(hl)
- ; inc hl
- ; ld b,(hl)
- ; inc hl
- ; ld e,(hl)
- ; inc hl
- ; ld d,(hl)
- ; ld ixh,b
- ; ld ixl,c
- ; ex de,hl
- pop bc ;37
- pop de ;47
- ld iy,NumberTable ;61
- ld a,%01111110 ;68 score sprite cycle 09 timed for safety
- out ($11),a ;11
- ld a,$FF ;18
- inc a ;22 4
- add ix,bc ;37 15
- adc hl,de ;52 15
- jr c,$-5 ;58 12/7
- ld bc,$3C11 ;68 score sprite cycle 10 timed for safety
- out (c),b ;12 cherry flavoured source team GO!
- add a,a ;16
- add a,a ;20 Out of order processing. Don't cry. It's quite alright.
- ld c,a ;24 assert("It's going to be okay");
- xor a ;28
- ld b,a ;32
- pop de ;42
- add ix,de ;57
- pop de ;67
- out ($11),a ;11 score sprite cycle 11. Near perfect timing.
- adc hl,de ;26
- add iy,bc ;41 BREAK!
- ld a,10 ;48 ten digits to look after. 1.000.000.000
- DSBDECSCOLP:
- ex af,af' ;52 62
- pop bc ;62 72
- pop de ;72 82
- ld a,(iy+0) ;91 101
- out ($11),a ;11
- ld a,$FF ;18
- inc a ;22
- add ix,bc ;37
- adc hl,de ;52
- jr c,$-5 ;59
- ld c,a ;63
- ld a,(iy+1) ;82
- out ($11),a ;11
- pop de ;21
- add ix,de ;36
- pop de ;46
- ld a,(iy+2) ;65 arghamahblabbles!
- nop ;69 BAD CODE! WORST ENEMY! *rolls newspaper* WHAP WHAP WHAP
- out ($11),a ;11
- adc hl,de ;26
- ld a,c ;30
- add a,a ;34
- add a,a ;38
- ld c,a ;42
- ld b,0 ;49
- ld a,(iy+3) ;68
- out ($11),a ;11
- ld iy,NumberTable ;25
- add iy,bc ;40
- ex af,af' ;44
- dec a ;48
- jp nz,DSBDECSCOLP ;58
- ld sp,(itemp1)
- ld iy,myflags
- jp DSBSCORCOLL
- DSBDHEXSC:
- ld b,5 ;Finishing off the rest of the display. Doing hex digits
- call DSBDRAWSP ;22 doesn't really need "acceleration".
- ld hl,NumberTable ;32 Getting at that zero at the start. Padding digits.
- ld b,4 ;39 Yesss.
- call DSBDRAWSP ;45 These are well-timed routines.
- ld hl,NumberTable
- ld b,4
- call DSBDRAWSP ;22
- ld hl,curscore+3
- ld a,(hl)
- dec hl
- call DrawHexToLCD ;Not timed. Makes it easier to use this for debugging
- ld a,(hl)
- dec hl
- call DrawHexToLCD
- ld a,(hl)
- dec hl
- call DrawHexToLCD
- ld a,(hl)
- call DrawHexToLCD
- DSBSCORCOLL:
- ;=============================================================================
- ;=============================================================================
- ; To display or not to display boss mode items? That's stuff after here!
- ;=============================================================================
- ;=============================================================================
- ;Edit: Add later.
- ld a,$20+09
- ld b,$00
- call DSBCOLBYT
- ld a,$20+08
- ld b,$80
- call DSBCOLBYT
- ; push hl
- ; pop hl
- ; push hl
- ; pop hl
- ; push hl
- ; pop hl
- ; ld a,$20+9
- ; out ($10),a
- ; push hl
- ; pop hl
- ; push hl
- ; pop hl
- ; ld a,(mdanmaku)
- ; call DrawHexToLCD
- ; ld a,(gametimer1)
- ; call DrawHexToLCD
- ret
- ;-----------------------------------------------------------------------------
- ;-----------------------------------------------------------------------------
- ;-----------------------------------------------------------------------------
- ;-----------------------------------------------------------------------------
- DSBNOSPRT:
- ld sp,(itemp4)
- ld hl,DSBbmbspt
- ld b,6
- call DSBDRAWSP
- ld b,8
- jp DSBNOSPRTR+2
- DSBswdspt: ;7 high
- .db %00000000
- .db %00000110
- .db %00001110
- .db %01101100
- .db %00110000
- .db %00111000
- .db %01001000
- DSBbmbspt: ;6 high
- .db %01111110
- .db %01110110
- .db %01110110
- .db %01111110
- .db %01011100
- .db %00000000
- DSBkilspr: ;7 high
- .db %00000000
- .db %01111110
- .db %01000110
- .db %01001110
- .db %01110010
- .db %01100010
- .db %01111110
- DSBscrspr: ;11 high. May not need all that. We'll be accelerating the
- .db %00000000 ;score counter in a few of the later cycles.
- .db %00000000
- .db %00111100
- .db %01111110
- .db %00100000
- .db %00011110
- .db %01111000
- .db %00000100
- .db %01111110
- .db %00111100
- .db %00000000
- ;Draw the remaining 7 ticks 8 spaces w/o sprite draw. Time-free. Draw tick nxt
- ;ROUTINES HERE ARE FOR DELAY PURPOSES.
- ;Naming schema:
- ;Entry: LCDDnn
- ;Exit: LCDRnn
- LCDD01: ;@32cc on jump, less 7 for load
- inc hl ;38
- dec hl ;44
- nop ;48
- jp LCDR01 ;62+11
- LCDD02: ;@32cc on jump, less 7 for load
- inc hl ;38
- dec hl ;44
- nop ;48
- nop ;52
- jp LCDR02 ;62+11
- DSBDRAWSP: ;45 Input B must be more than 1.
- dec b ;49
- ld a,(hl) ;56
- inc hl ;62
- nop ;66
- out ($11),a ;11
- DSBDRAWSPB: ;break-in
- ld a,(hl) ;18
- inc hl ;24
- push hl ;35
- pop hl ;45
- nop ;49
- nop ;53
- djnz $-8 ;66/61
- dec bc ;67
- out ($11),a ;11
- ret ;22
- DSBDRAWNM:
- cp 100
- jr c,$+4
- ld a,99
- ld bc,$0AFF ; B=-1,C=10 for count
- ld de,$01FF
- inc c
- sub b
- jp nc,$-2
- add a,b
- inc e
- sub d
- jp nc,$-2
- inc a
- out ($11),a ;spacer before number
- ld b,a
- ld d,a
- ld a,e
- add a,a
- add a,a
- add a,e ;x5
- ld e,a
- ld hl,DSBDRAWNMTBL
- add hl,de
- ex de,hl
- ld a,c
- add a,a
- add a,a
- add a,c
- ld c,a
- ld hl,DSBDRAWNMTBL
- add hl,bc
- ld bc,$050F
- ld a,(de) ;ones digit
- xor (hl) ;tens digit
- and c
- xor (hl) ;write tens digit into high nibble.
- out ($11),a ;11
- inc hl ;17
- inc de ;23
- djnz $-8 ;31
- ret ;41
- DSBDRAWNMTBL:
- .db %01000100 ;0
- .db %10101010 ;
- .db %10101010 ;
- .db %10101010 ;
- .db %01000100 ;
- .db %01000100 ;1
- .db %11001100 ;
- .db %01000100 ;
- .db %01000100 ;
- .db %11101110 ;
- .db %11001100 ;2
- .db %00100010 ;
- .db %01000100 ;
- .db %10001000 ;
- .db %11101110 ;
- .db %11001100 ;3
- .db %00100010 ;
- .db %11001100 ;
- .db %00100010 ;
- .db %11001100 ;
- .db %10101010 ;4
- .db %10101010 ;
- .db %11101110 ;
- .db %00100010 ;
- .db %00100010 ;
- .db %11101110 ;5
- .db %10001000 ;
- .db %11001100 ;
- .db %00100010 ;
- .db %11001100 ;
- .db %01100110 ;6
- .db %10001000 ;
- .db %11001100 ;
- .db %10101010 ;
- .db %11101110 ;
- .db %11101110 ;7
- .db %00100010 ;
- .db %01000100 ;
- .db %01000100 ;
- .db %01000100 ;
- .db %11101110 ;8
- .db %10101010 ;
- .db %01000100 ;
- .db %10101010 ;
- .db %11101110 ;
- .db %11101110 ;9
- .db %10101010 ;
- .db %01100110 ;
- .db %00100010 ;
- .db %11001100 ;
- DSBCOLBYT: ;A=$10out, B=$11out for 64 cycles
- push hl
- pop hl
- push hl
- pop hl
- out ($10),a
- ld a,b
- ld b,64
- push hl
- pop hl
- push hl
- pop hl
- out ($11),a
- djnz $-6
- ret
- billiontab: ;lsw first
- .dw $3600,$C465,$CA00,$3B9A ;1,000,000,000
- .dw $1F00,$FA0A,$E100,$05F5 ; 100,000,000
- .dw $6980,$FF67,$9680,$0098 ; 10,000,000
- .dw $BDC0,$FFF0,$4240,$000F ; 1,000,000
- .dw $7960,$FFFE,$86A0,$0001 ; 100,000
- .dw $D8F0,$FFFF,$2710,$0000 ; 10,000
- .dw $FC18,$FFFF,$03E8,$0000 ; 1,000
- .dw $FF9C,$FFFF,$0064,$0000 ; 100
- .dw $FFF6,$FFFF,$000A,$0000 ; 10
- .dw $FFFF,$FFFF,$0001,$0000 ; 1
- .dw $FFFF,$FFFF ; dummy entry
- ;=============================================================================
- ;=============================================================================
- ;=============================================================================
- BARDEBUG:
- ld sp,(itemp4)
- ld a,$AA \ call DrawHexToLCD
- ret
- DrawHexToLCD: ;input: A=numbertowrite
- push af
- push bc
- push de
- push hl
- ld c,a
- ld de,NumberTable
- bit binscoremode,(iy+gamesettings)
- jr z,$+5
- ld de,BinaryNumberTable
- and %11110000
- rrca
- rrca
- ld L,a
- ld h,0
- add hl,de
- call WriteHexDigitsToLCD
- ld a,c
- and %00001111
- ld L,a
- ld h,0
- add hl,hl
- add hl,hl
- add hl,de
- call WriteHexDigitsToLCD
- pop hl
- pop de
- pop bc
- pop af
- ret
- WriteHexDigitsToLCD:
- ld b,4
- ld a,(hl)
- out ($11),a
- push hl
- pop hl
- push hl
- pop hl
- push hl
- pop hl
- inc hl
- djnz WriteHexDigitsToLCD+2
- ret
- NumberTable:
- .db %00111000 ;0
- .db %01000100
- .db %00111000
- .db %00000000
- .db %01001000 ;1
- .db %01111100
- .db %01000000
- .db %00000000
- .db %01100100 ;2
- .db %01010100
- .db %01001000
- .db %00000000
- .db %01000100 ;3
- .db %01010100
- .db %00101000
- .db %00000000
- .db %00011100 ;4
- .db %00010000
- .db %01111100
- .db %00000000
- .db %01011100 ;5
- .db %01010100
- .db %00100100
- .db %00000000
- .db %01111000 ;6
- .db %01010100
- .db %01110100
- .db %00000000
- .db %00000100 ;7
- .db %01110100
- .db %00001100
- .db %00000000
- .db %01101100 ;8
- .db %01010100
- .db %01101100
- .db %00000000
- .db %01011100 ;9
- .db %01010100
- .db %00111100
- .db %00000000
- .db %01111000 ;A
- .db %00010100
- .db %01111000
- .db %00000000
- .db %01111100 ;B
- .db %01010100
- .db %00101000
- .db %00000000
- .db %00111000 ;C
- .db %01000100
- .db %01000100
- .db %00000000
- .db %01111100 ;D
- .db %01000100
- .db %00111000
- .db %00000000
- .db %01111100 ;E
- .db %01010100
- .db %01000100
- .db %00000000
- .db %01111100 ;F
- .db %00010100
- .db %00000100
- .db %00000000
- BinaryNumberTable:
- .db %01000010 ;0
- .db %00000000
- .db %00000000
- .db %00000000
- .db %01000010 ;1
- .db %00000000
- .db %00000000
- .db %00111100
- .db %01000010 ;2
- .db %00000000
- .db %00111100
- .db %00000000
- .db %01000010 ;3
- .db %00000000
- .db %00111100
- .db %00111100
- .db %01000010 ;4
- .db %00111100
- .db %00000000
- .db %00000000
- .db %01000010 ;5
- .db %00111100
- .db %00000000
- .db %00111100
- .db %01000010 ;6
- .db %00111100
- .db %00111100
- .db %00000000
- .db %01000010 ;7
- .db %00111100
- .db %00111100
- .db %00111100
- .db %01111110 ;8
- .db %00000000
- .db %00000000
- .db %00000000
- .db %01111110 ;9
- .db %00000000
- .db %00000000
- .db %00111100
- .db %01111110 ;A
- .db %00000000
- .db %00111100
- .db %00000000
- .db %01111110 ;B
- .db %00000000
- .db %00111100
- .db %00111100
- .db %01111110 ;C
- .db %00111100
- .db %00000000
- .db %00000000
- .db %01111110 ;D
- .db %00111100
- .db %00000000
- .db %00111100
- .db %01111110 ;E
- .db %00111100
- .db %00111100
- .db %00000000
- .db %01111110 ;F
- .db %00111100
- .db %00111100
- .db %00111100
- .echo "LCD code section : ",$-_drawlcd.z80," bytes."
Advertisement
Add Comment
Please, Sign In to add comment