mirror of
https://github.com/a2-4am/4cade.git
synced 2024-09-27 12:57:21 +00:00
464 lines
14 KiB
Plaintext
464 lines
14 KiB
Plaintext
;license:MIT
|
|
;(c) 2018-9 by 4am
|
|
;
|
|
; Double hi-res slideshows
|
|
;
|
|
; Public functions
|
|
; - DHGRTitleSlideshow
|
|
; - DHGRActionSlideshow
|
|
; - DHGRSingle
|
|
; - BlankHGR
|
|
; - HGRMode
|
|
;
|
|
|
|
;------------------------------------------------------------------------------
|
|
; DHGRTitleSlideshow
|
|
; execute a slideshow of double hi-res title screenshots
|
|
;
|
|
; safe to call if machine only has 64K (does nothing and exits)
|
|
;
|
|
; in: none
|
|
; out: everything clobbered
|
|
; graphics mode reset to display hi-res screen, which is blank
|
|
;------------------------------------------------------------------------------
|
|
DHGRTitleSlideshow
|
|
bit MachineStatus ; only run DHGR slideshow if we have 128K
|
|
bvc DHGRRTS
|
|
jsr LoadDHGRTransition ; load transition effect code at $6000
|
|
jsr BlankDHGR ; switch to DHGR mode with initial blank screen
|
|
jsr okvs_iter ; cycle through all listed DHGR files
|
|
!word gSlideshowStore
|
|
!word DHGRTitleCallback ; address of callback (called on each file)
|
|
beq BlankHGR ; switch back to HGR mode with initial blank screen on exit
|
|
; (always branches because Z=1 on exit of okvs_iter)
|
|
|
|
;------------------------------------------------------------------------------
|
|
; DHGRActionSlideshow
|
|
; execute a slideshow of double hi-res action screenshots
|
|
;
|
|
; safe to call if machine only has 64K (does nothing and exits)
|
|
;
|
|
; in: none
|
|
; out: everything clobbered
|
|
; graphics mode reset to display hi-res screen, which is blank
|
|
;------------------------------------------------------------------------------
|
|
DHGRActionSlideshow
|
|
bit MachineStatus ; only run DHGR slideshow if we have 128K
|
|
bvc DHGRRTS
|
|
jsr LoadDHGRTransition ; load transition effect code at $6000
|
|
jsr BlankDHGR ; switch to DHGR mode with initial blank screen
|
|
jsr okvs_iter ; cycle through all listed DHGR files
|
|
!word gSlideshowStore
|
|
!word DHGRActionCallback ; address of callback (called on each file)
|
|
beq BlankHGR ; switch back to HGR mode with initial blank screen on exit
|
|
; (always branches because Z=1 on exit of okvs_iter)
|
|
|
|
;------------------------------------------------------------------------------
|
|
; DHGRSingle
|
|
; display a single double hi-res screenshot, with transition effect
|
|
;
|
|
; safe to call if machine only has 64K (does nothing and exits)
|
|
;
|
|
; in: none
|
|
; out: everything clobbered
|
|
; graphics mode reset to display hi-res screen, which is blank
|
|
;------------------------------------------------------------------------------
|
|
DHGRSingle
|
|
bit MachineStatus ; only show DHGR screenshots if we have 128K
|
|
bvc DHGRRTS
|
|
+STAY +
|
|
jsr BlankDHGR ; switch to DHGR mode with initial blank screen
|
|
jsr LoadDHRFile ; load DHGR file at $4000/main and $4000/aux
|
|
!word kRootDirectory
|
|
+ !word $FDFD ; SMC
|
|
jsr LoadDHGRTransition ; load transition effect code at $6000
|
|
jsr ExecuteTransitionAt6000AndWait
|
|
; switch back to HGR mode with initial blank screen on exit
|
|
; /!\ execution falls through here to BlankHGR
|
|
;------------------------------------------------------------------------------
|
|
; BlankHGR
|
|
; clear and show HGR page 1 without flickering
|
|
;
|
|
; in: none
|
|
; out: text page clobbered (but screen holes preserved)
|
|
; A/X/Y=0 (guaranteed by ClearHGR1)
|
|
; $2000..$3FFF cleared
|
|
;------------------------------------------------------------------------------
|
|
BlankHGR
|
|
jsr Home
|
|
jsr ClearHGR1 ; clear hi-res screen 1
|
|
bit PAGE1 ; show hi-res screen 1 (now blank)
|
|
; /!\ execution falls through here to HGRMode
|
|
;------------------------------------------------------------------------------
|
|
; HGRMode
|
|
; twiddles softswitches to set HGR mode (does not set page 1 or 2)
|
|
;
|
|
; in: none
|
|
; out: all registers preserved
|
|
;------------------------------------------------------------------------------
|
|
HGRMode
|
|
bit $C057
|
|
GRMode
|
|
bit $C052
|
|
bit $C050
|
|
DHGRRTS rts
|
|
|
|
;------------------------------------------------------------------------------
|
|
; LoadDHGRTransition [private]
|
|
; looks up name of next DHGR transition effect in DFX.CONF and loads that file
|
|
; at $6000
|
|
|
|
; in: gDFXStore has been initialized
|
|
; gGlobalPrefsStore has been initialized
|
|
; out: all registers and flags clobbered
|
|
; $6000..$BFFF/main contains transition effect code
|
|
;------------------------------------------------------------------------------
|
|
LoadDHGRTransition
|
|
jsr LoadFile ; load DHGR transition effects list into $8000
|
|
!word kRootDirectory
|
|
!word kDFXConfFile
|
|
- !word $8000
|
|
jsr ParseKeyValueList ; parse DHGR transition effects list into $6000
|
|
!word gDFXStore
|
|
!word -
|
|
!byte 0
|
|
|
|
jsr pref_get ; get DHGR transition effect from prefs
|
|
!word kNextDFX
|
|
!word gDFXStore
|
|
+STAY ++ ; A/Y = filename (don't load file yet)
|
|
; X = index of the transition in DFX store
|
|
+LDADDR gDFXStore
|
|
jsr okvs_next ; get transition after this one
|
|
+STAY +
|
|
|
|
jsr pref_set ; update prefs store and save to disk
|
|
!word kNextDFX
|
|
+ !word $FDFD ; SMC
|
|
|
|
jsr LoadFile ; now load transition effect code into $6000
|
|
!word kFXDirectory
|
|
++ !word $FDFD ; SMC
|
|
!word $6000
|
|
rts
|
|
|
|
;------------------------------------------------------------------------------
|
|
; DHGRTitleCallback [private]
|
|
; callback called by okvs_iter on gSlideshowStore
|
|
; to load and display a single DHGR title screenshot
|
|
|
|
; in: A/Y contains address of filename (name only, path is always /TITLE.DHGR/)
|
|
; X contains 0-based index of the current record in gSlideshowStore
|
|
; out: all registers and flags clobbered
|
|
; $0800..$1EFF preserved (this contains the gSlideshowStore OKVS data)
|
|
; $2000..$BFFF clobbered by graphics data and transition code
|
|
; $2000..$5FFF/aux clobbered
|
|
;------------------------------------------------------------------------------
|
|
DHGRTitleCallback
|
|
bit KBD
|
|
bmi DHGRRTS
|
|
|
|
+STAY +
|
|
|
|
jsr GetGameInfo
|
|
; if game is not found (C will be set here), it means it can't be played on
|
|
; this machine due to memory or joystick requirements, so we don't display
|
|
; it in slideshows
|
|
bcs DHGRRTS
|
|
stx gGameToLaunch
|
|
|
|
; load DHGR screenshot at $4000/main and $4000/aux
|
|
jsr LoadDHRFile
|
|
!word kDHGRTitleDirectory
|
|
+ !word $FDFD
|
|
|
|
jmp ExecuteTransitionAt6000AndWait
|
|
|
|
;------------------------------------------------------------------------------
|
|
; DHGRActionCallback [private]
|
|
; callback called by okvs_iter on gSlideshowStore
|
|
; to load and display a single DHGR action screenshot
|
|
|
|
; in: A/Y contains address of filename (name only, path is always /ACTION.DHGR/)
|
|
; X contains 0-based index of the current record in gSlideshowStore
|
|
; out: all registers and flags clobbered
|
|
; $0800..$1EFF preserved (this contains the gSlideshowStore OKVS data)
|
|
; $2000..$BFFF clobbered by graphics data and transition code
|
|
; $2000..$5FFF/aux clobbered
|
|
;------------------------------------------------------------------------------
|
|
DHGRActionCallback
|
|
bit KBD
|
|
bmi DHGRRTS
|
|
|
|
+STAY +
|
|
|
|
jsr GetGameInfoInActionSlideshow
|
|
; if game name is not found (C will be set here), it means the game
|
|
; can't be played due to memory or joystick requirements, so we hide
|
|
; it from slideshows
|
|
bcs DHGRRTS
|
|
+STAY SAVE ; (SAVE) -> game title
|
|
stx gGameToLaunch
|
|
|
|
; load DHGR screenshot at $4000/main and $4000/aux
|
|
jsr LoadDHRFile
|
|
!word kDHGRActionDirectory
|
|
+ !word $FDFD
|
|
|
|
; display game name in the bottom-left corner
|
|
lda #22
|
|
sta VTAB
|
|
lda #0 ; solid horizontal bar character
|
|
jsr @resetline
|
|
lda (SAVE),y ; (SAVE) -> game title, Y = 0, so A = title length
|
|
clc
|
|
adc #$03
|
|
sta gPathname
|
|
lda #7 ; top-right rounded corner character
|
|
jsr @drawline
|
|
|
|
inc VTAB
|
|
lda #" "
|
|
jsr @resetline
|
|
lda (SAVE),y ; A = title length
|
|
tay
|
|
- lda (SAVE),y
|
|
sta gPathname+1,y
|
|
dey
|
|
bne -
|
|
lda #3 ; solid vertical bar character
|
|
jsr @drawline
|
|
|
|
jmp ExecuteTransitionAt6000AndWait
|
|
@resetline
|
|
ldy #40
|
|
- sta gPathname,y
|
|
dey
|
|
bne -
|
|
sty HTAB
|
|
rts
|
|
@drawline
|
|
ldy gPathname
|
|
sta gPathname,y
|
|
lda HTAB
|
|
pha
|
|
+LDADDR gPathname
|
|
sec
|
|
jsr DrawString
|
|
;RedrawForDHGR
|
|
jsr SwitchToBank2
|
|
pla
|
|
sta HTAB
|
|
ldx gPathname
|
|
dex
|
|
|
|
clc
|
|
lda DBIRow0+2
|
|
sta @row0a+2
|
|
sta @row0b+2
|
|
sta @row0c+2
|
|
adc #$04
|
|
sta @row1a+2
|
|
sta @row1b+2
|
|
sta @row1c+2
|
|
adc #$04
|
|
sta @row2a+2
|
|
sta @row2b+2
|
|
sta @row2c+2
|
|
adc #$04
|
|
sta @row3a+2
|
|
sta @row3b+2
|
|
sta @row3c+2
|
|
adc #$04
|
|
sta @row4a+2
|
|
sta @row4b+2
|
|
sta @row4c+2
|
|
adc #$04
|
|
sta @row5a+2
|
|
sta @row5b+2
|
|
sta @row5c+2
|
|
adc #$04
|
|
sta @row6a+2
|
|
sta @row6b+2
|
|
sta @row6c+2
|
|
adc #$04
|
|
sta @row7a+2
|
|
sta @row7b+2
|
|
sta @row7c+2
|
|
|
|
lda DBIRow0+1
|
|
sta @row0a+1
|
|
sta @row0b+1
|
|
sta @row0c+1
|
|
sta @row1a+1
|
|
sta @row1b+1
|
|
sta @row1c+1
|
|
sta @row2a+1
|
|
sta @row2b+1
|
|
sta @row2c+1
|
|
sta @row3a+1
|
|
sta @row3b+1
|
|
sta @row3c+1
|
|
sta @row4a+1
|
|
sta @row4b+1
|
|
sta @row4c+1
|
|
sta @row5a+1
|
|
sta @row5b+1
|
|
sta @row5c+1
|
|
sta @row6a+1
|
|
sta @row6b+1
|
|
sta @row6c+1
|
|
sta @row7a+1
|
|
sta @row7b+1
|
|
sta @row7c+1
|
|
|
|
@loop
|
|
|
|
@row0a lda $FDFD,x
|
|
jsr HGRByteToDHGRBytes
|
|
lda $00
|
|
@row0b sta $FDFD,x
|
|
lda $01
|
|
sta WRITEAUXMEM
|
|
@row0c sta $FDFD,x
|
|
sta WRITEMAINMEM
|
|
|
|
@row1a lda $FDFD,x
|
|
jsr HGRByteToDHGRBytes
|
|
lda $00
|
|
@row1b sta $FDFD,x
|
|
lda $01
|
|
sta WRITEAUXMEM
|
|
@row1c sta $FDFD,x
|
|
sta WRITEMAINMEM
|
|
|
|
@row2a lda $FDFD,x
|
|
jsr HGRByteToDHGRBytes
|
|
lda $00
|
|
@row2b sta $FDFD,x
|
|
lda $01
|
|
sta WRITEAUXMEM
|
|
@row2c sta $FDFD,x
|
|
sta WRITEMAINMEM
|
|
|
|
@row3a lda $FDFD,x
|
|
jsr HGRByteToDHGRBytes
|
|
lda $00
|
|
@row3b sta $FDFD,x
|
|
lda $01
|
|
sta WRITEAUXMEM
|
|
@row3c sta $FDFD,x
|
|
sta WRITEMAINMEM
|
|
|
|
@row4a lda $FDFD,x
|
|
jsr HGRByteToDHGRBytes
|
|
lda $00
|
|
@row4b sta $FDFD,x
|
|
lda $01
|
|
sta WRITEAUXMEM
|
|
@row4c sta $FDFD,x
|
|
sta WRITEMAINMEM
|
|
|
|
@row5a lda $FDFD,x
|
|
jsr HGRByteToDHGRBytes
|
|
lda $00
|
|
@row5b sta $FDFD,x
|
|
lda $01
|
|
sta WRITEAUXMEM
|
|
@row5c sta $FDFD,x
|
|
sta WRITEMAINMEM
|
|
|
|
@row6a lda $FDFD,x
|
|
jsr HGRByteToDHGRBytes
|
|
lda $00
|
|
@row6b sta $FDFD,x
|
|
lda $01
|
|
sta WRITEAUXMEM
|
|
@row6c sta $FDFD,x
|
|
sta WRITEMAINMEM
|
|
|
|
@row7a lda $FDFD,x
|
|
jsr HGRByteToDHGRBytes
|
|
lda $00
|
|
@row7b sta $FDFD,x
|
|
lda $01
|
|
sta WRITEAUXMEM
|
|
@row7c sta $FDFD,x
|
|
sta WRITEMAINMEM
|
|
|
|
inc HTAB
|
|
dex
|
|
bmi +
|
|
jmp @loop
|
|
+
|
|
jmp SwitchToBank1
|
|
|
|
HGRByteToDHGRBytes
|
|
;1GFEDCBA ->
|
|
;1GGFFEED (main) +
|
|
;1DCCBBAA (aux)
|
|
;
|
|
; in: A = HGR byte
|
|
; out: $00 = corresponding DHGR byte in mainmem
|
|
; $01 = corresponding DHGR byte in auxmem
|
|
; preserves X
|
|
|
|
ldy #%10000000
|
|
sty $00
|
|
sty $01
|
|
pha
|
|
and #%00000001
|
|
beq +
|
|
lda #%10000011
|
|
sta $01
|
|
+ pla
|
|
pha
|
|
and #%00000010
|
|
beq +
|
|
lda $01
|
|
clc
|
|
adc #%00001100
|
|
sta $01
|
|
+ pla
|
|
pha
|
|
and #%00000100
|
|
beq +
|
|
lda $01
|
|
clc
|
|
adc #%00110000
|
|
sta $01
|
|
+ pla
|
|
pha
|
|
and #%00001000
|
|
beq +
|
|
lda $01
|
|
clc
|
|
adc #%01000000
|
|
sta $01
|
|
inc $00
|
|
+ pla
|
|
pha
|
|
and #%00010000
|
|
beq +
|
|
lda $00
|
|
clc
|
|
adc #%00000110
|
|
sta $00
|
|
+ pla
|
|
pha
|
|
and #%00100000
|
|
beq +
|
|
lda $00
|
|
clc
|
|
adc #%00011000
|
|
sta $00
|
|
+ pla
|
|
;pha
|
|
and #%01000000
|
|
beq +
|
|
lda $00
|
|
clc
|
|
adc #%01100000
|
|
sta $00
|
|
+ rts
|