Merge pull request #2 from peterferrie/master

a bit smaller again
This commit is contained in:
4am 2018-01-08 19:05:12 -05:00 committed by GitHub
commit 4fd10d51e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,73 +38,30 @@ MACHID = $BF98
inputfilebuffer
!fill $40
Start
ldx #(CodeEnd-CodeStart)-1; copy code to lower memory so we can load graphic at $2000
- lda CodeStart,x
sta $00fe,x
ldx #(CodeEnd-CodeStart); copy code to lower memory so we can load graphic at $2000
- ldy CodeStart-1,x
sty $4f,x
dex
bpl -
txs
bne -
;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)
+ jsr MLI ; open file
!byte kMLIOpen
!word mliParamForOpen
sty <mliparam ; set parameter count for MLI call
; both Read and Quit accept four parameters
; (Y is 4 from above)
jmp ReadFile
CodeStart
!pseudopc $fe {
!word $2000 ; used by main->aux copy loop
!word Open-1 ; on stack for first MLI call
Open
!byte kMLIOpen ; stack-based params for Open MLI call
!word mliParamForOpen
jsr Read1 ; read first half of graphic (belongs in auxmem)
bcs Close ; error during open or read? close & quit
;DHGRCopy
sta $C00A
sta $C000
sta $C005 ; read from mainmem, write to auxmem
- lda ($ff,x) ; ($fe) because X is #$FF
sta ($ff,x)
inc $fe
bne -
inc $ff
bit $ff ; copy until $4000
bvc -
sta $C004 ; read/write from mainmem
jsr Read2 ; read second half of graphic (stays in main memory)
Close
php ; save MLI result
jsr MLI ; close all files
!byte kMLIClose
!word mliParamForClose
plp ; restore MLI result
bcs Quit ; any error? quit without displaying
;DHGRShow
lda $C05E ; DHGR mode
sta $C00D
bit $C050
bit $C054
bit $C052
bit $C057
;WaitForKey
- lda $C000
bpl -
Quit
lsr mlicmd ; MLI_QUIT ($65) is half of MLI_READ ($CA) so that's great
Read1
ldy #kMLIReadOrQuitCount
sty mliparam
Read2
jsr MLI
mlicmd !byte kMLIRead
!word mliparam
rts
mliParamForClose
!byte kMLICloseCount
!byte 0 ; close all files
!pseudopc $50 {
softswitches ; array of low bytes for $c0xx accesses
!byte 4,0,$5e,$0d,$50,$52,$54,$57
softswitches_e
mliParamForOpen
!byte kMLIOpenCount
@ -112,8 +69,51 @@ mliParamForOpen
!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
!word $2000 ; data length
!byte $00
CopyToAux=*+1
CopyToAuxLow=*+1
CopyToAuxHigh=*+2
ReadFile
jsr Read ; JSR (#$20) is high part of data length
; Read is replaced by read length ($2000)
; and then used by main->aux copy loop
; 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 (SoftswitchBase),y ; restore main memory access, enable DHGR graphics display
dex
bpl -
jsr Read ; read second half of graphic (stays in main memory)
; does not return if error
;DHGRShow
;WaitForKey
SoftswitchBase=*+1
- 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