a2fc.system/src/a2fc.system.a

120 lines
3.3 KiB
Plaintext
Raw Normal View History

2018-01-08 00:25:59 +00:00
!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
2018-01-08 15:43:58 +00:00
kMLIReadOrQuitCount = $04
2018-01-08 00:25:59 +00:00
kMLICloseCount = $01
;
; other stuff
;
aFileBuffer = $9200
MLI = $BF00
2018-01-08 15:43:58 +00:00
MACHID = $BF98
2018-01-08 00:25:59 +00:00
2018-01-08 15:43:58 +00:00
jmp Start ; magic jump
!byte $EE,$EE ; magic bytes
!byte $40 ; length of inputfile buffer
2018-01-08 00:25:59 +00:00
inputfilebuffer
!fill $40
Start
2018-01-08 15:43:58 +00:00
ldx #(CodeEnd-CodeStart)-1; copy code to lower memory so we can load graphic at $2000
2018-01-08 05:53:39 +00:00
- lda CodeStart,x
2018-01-08 20:09:43 +00:00
sta $00f7,x
dex
2018-01-08 05:53:39 +00:00
bpl -
txs
2018-01-08 15:43:58 +00:00
;CheckFor128K
lda MACHID
and #$30
cmp #$30 ; 128K?
beq + ; yes, continue
stx inputfilebuffer ; no, trash inputfilebuffer so open fails and we quit immediately
+ jmp MLI ; exit via MLI (stack is arranged to execute Open MLI call)
2018-01-08 00:25:59 +00:00
CodeStart
2018-01-08 20:09:43 +00:00
!pseudopc $f7 {
2018-01-08 18:21:52 +00:00
softswitches
2018-01-08 20:09:43 +00:00
!byte $50,$52,$54,$57,$0d,$5e
2018-01-08 18:21:52 +00:00
mliParamForClose
!byte kMLICloseCount
!byte 0 ; close all files, also low part of pointer
!byte $20 ; used by main->aux copy loop
2018-01-08 15:43:58 +00:00
!word Open-1 ; on stack for first MLI call
2018-01-08 00:25:59 +00:00
Open
2018-01-08 15:43:58 +00:00
!byte kMLIOpen ; stack-based params for Open MLI call
!word mliParamForOpen
2018-01-08 18:21:52 +00:00
ldx #kMLIReadOrQuitCount ; they just happen to be the same number
stx mliparam
jsr Read ; read first half of graphic (belongs in auxmem)
; does not return if error
2018-01-08 00:25:59 +00:00
;DHGRCopy
sta $C00A
sta $C000
sta $C005 ; read from mainmem, write to auxmem
2018-01-08 18:21:52 +00:00
- lda ($fe-kMLIReadOrQuitCount,x)
sta ($fe-kMLIReadOrQuitCount,x)
2018-01-08 05:53:39 +00:00
inc $fe
2018-01-08 03:58:13 +00:00
bne -
2018-01-08 05:53:39 +00:00
inc $ff
2018-01-08 15:43:58 +00:00
bit $ff ; copy until $4000
2018-01-08 05:53:39 +00:00
bvc -
sta $C004 ; read/write from mainmem
2018-01-08 18:21:52 +00:00
jsr Read ; read second half of graphic (stays in main memory)
; does not return if error
2018-01-08 00:25:59 +00:00
;DHGRShow
2018-01-08 20:09:43 +00:00
inx
2018-01-08 18:21:52 +00:00
- ldy softswitches,x
sta $c000,y ; enable graphics display
dex
bpl -
2018-01-08 00:25:59 +00:00
;WaitForKey
- lda $C000
bpl -
2018-01-08 18:21:52 +00:00
Close
jsr MLI ; close all files
!byte kMLIClose
!word mliParamForClose
2018-01-08 00:25:59 +00:00
Quit
2018-01-08 15:43:58 +00:00
lsr mlicmd ; MLI_QUIT ($65) is half of MLI_READ ($CA) so that's great
2018-01-08 18:21:52 +00:00
Read
jsr MLI
mlicmd !byte kMLIRead
2018-01-08 00:25:59 +00:00
!word mliparam
2018-01-08 18:21:52 +00:00
bcs Close ; error during open or read? close & quit
2018-01-08 00:25:59 +00:00
rts
mliParamForOpen
!byte kMLIOpenCount
2018-01-08 00:25:59 +00:00
!word inputfilebuffer
!byte <aFileBuffer
mliparam
!byte >aFileBuffer
!byte $00 ; ProDOS file refnum (filled by MLI_OPEN call)
!word $2000 ; data address
!word $2000 ; data length
2018-01-08 00:25:59 +00:00
}
CodeEnd