mirror of
https://github.com/a2-4am/a2fc.system.git
synced 2024-06-26 23:29:31 +00:00
117 lines
3.4 KiB
Plaintext
117 lines
3.4 KiB
Plaintext
!cpu 6502
|
|
!to "../build/A2FC.SYSTEM#FF2000",plain
|
|
*=$2000
|
|
;
|
|
; A2FC.SYSTEM
|
|
; (c) 2018 by 4am
|
|
; a very small DHGR graphics viewer
|
|
; takes pathname of .a2fc file (in $2006),
|
|
; loads it,
|
|
; displays it,
|
|
; waits for key,
|
|
; quits via MLI
|
|
;
|
|
|
|
;
|
|
; MLI commands
|
|
;
|
|
kMLIOpen = $C8
|
|
kMLIRead = $CA
|
|
kMLIClose = $CC
|
|
kMLIQuit = $65
|
|
;
|
|
; MLI parameter counts
|
|
;
|
|
kMLIOpenCount = $03
|
|
kMLIReadOrQuitCount = $04
|
|
kMLICloseCount = $01
|
|
;
|
|
; other stuff
|
|
;
|
|
aFileBuffer = $9200
|
|
MLI = $BF00
|
|
MACHID = $BF98
|
|
|
|
jmp Start ; magic jump
|
|
!byte $EE,$EE ; magic bytes
|
|
!byte $40 ; length of inputfile buffer
|
|
inputfilebuffer
|
|
!fill $40
|
|
Start
|
|
ldx #(CodeEnd-CodeStart)-1; copy code to lower memory so we can load graphic at $2000
|
|
- lda CodeStart,x
|
|
sta $50,x
|
|
dex
|
|
bpl -
|
|
;CheckFor128K
|
|
lda MACHID
|
|
and #$30
|
|
cmp #$30 ; 128K?
|
|
beq + ; yes, continue
|
|
stx inputfilebuffer ; no, trash inputfilebuffer so open fails and we quit immediately
|
|
+ jmp Open
|
|
|
|
CodeStart
|
|
!pseudopc $50 {
|
|
softswitches ; array of low bytes for $c0xx accesses
|
|
!byte 0,$5e,$0d,$50,$52,$54,$57,4
|
|
softswitches_e
|
|
|
|
mliParamForOpen
|
|
!byte kMLIOpenCount
|
|
!word inputfilebuffer
|
|
!byte <aFileBuffer
|
|
mliparam
|
|
!byte >aFileBuffer
|
|
mliParamForClose ; first handle will be 1, the same as kMLICloseCount
|
|
!byte $00 ; ProDOS file refnum (filled by MLI_OPEN call)
|
|
!word $2000 ; data address
|
|
!byte $00
|
|
Open
|
|
CopyToAux=*+2 ; +1 of real address because indexed by X (#$FF) below
|
|
CopyToAuxLow=*+1
|
|
CopyToAuxHigh=*+2
|
|
JSR MLI ; JSR (#$20) is high part of data length
|
|
; MLI is replaced by read length ($2000)
|
|
; and then used by main->aux copy loop
|
|
!byte kMLIOpen
|
|
!word mliParamForOpen
|
|
lda #4 ; both Read and Quit accept four parameters
|
|
sta mliparam ; set parameter count for MLI call
|
|
jsr Read ; read first half of graphic (belongs in auxmem)
|
|
; does not return if error
|
|
;DHGRCopy
|
|
sta $C005 ; read from mainmem, write to auxmem
|
|
- lda (CopyToAux,x)
|
|
sta (CopyToAux,x)
|
|
inc <(CopyToAuxLow)
|
|
bne -
|
|
inc <(CopyToAuxHigh)
|
|
bit <(CopyToAuxHigh) ; copy until $4000
|
|
bvc -
|
|
ldx #(softswitches_e-softswitches)-1
|
|
- ldy softswitches,x
|
|
sta (WaitForKey+1),y ; enable graphics display
|
|
dex
|
|
bpl -
|
|
jsr Read ; read second half of graphic (stays in main memory)
|
|
; does not return if error
|
|
;DHGRShow
|
|
WaitForKey
|
|
- lda $C000
|
|
bpl -
|
|
Close
|
|
jsr MLI ; close all files
|
|
!byte kMLIClose
|
|
!word mliParamForClose
|
|
Quit
|
|
lsr <mlicmd ; MLI_QUIT ($65) is half of MLI_READ ($CA) so that's great
|
|
Read
|
|
jsr MLI
|
|
mlicmd !byte kMLIRead
|
|
!word mliparam
|
|
bcs Close ; error during open or read? close & quit
|
|
rts
|
|
}
|
|
CodeEnd
|