fixed for direct BSAVE loading from bmp2dhr

This commit is contained in:
furry one 2017-03-25 13:29:34 -04:00
parent 1423865f6d
commit 436d67c2bf
2 changed files with 84 additions and 52 deletions

126
main.s
View File

@ -13,7 +13,7 @@
mx %11 ; assemble in 8-bit mode
typ $06 ; type binary (for merlin32)
org $7000 ; system programs execute at $2000
org $2000 ; system programs execute at $2000
dsk main ; this is the main .system blob
; we probably want to relocate to higher ground, to free hgr1
@ -28,66 +28,95 @@ start
lda #$A0 ; why do I do this?
jsr $C300 ; init 80 column card
;bit DHRON ; turn double-hires on
;bit TEXTOFF ; turn on graphics mode
;bit MIXEDON ; use bottom 4 rows as text
jsr DL_SetDLRMixMode ; turn on double lo-res
; init drawing loop first
main_init
ldx #4 ; do 4 downto 1
stz mdlgr_src ; reset smc
lda #$50
sta mdlgr_src+1
main_loop
phx ; save counter
jsr MoveDLGRBinary ; call function
lda #$10 ; delay a bit
jsr $fca8
lda #$FF
jsr $fca8
plx ; restore loop counter
dex ; decrement
bne main_loop ; not done yet - branch and continue
jmp main_init ; jump back and loop forever
; ====================================================================================================
; draw a 80x48 glyph
; move a Double Lo-Res Binary blob from BMP2DHR to video memory
; this does not stomp on screen holes
draw80x48glyph
stz curline ; initialize curline to 0
stz startloop+4 ; reset self modifying code
stz startloop+1
lda #$50
sta startloop+2
lda #$04
sta startloop+5
; format is BSAVE, with 0 in slot holes. preserved during copy.
start2
; input: reset mdlgr_src to your source binary
; output: binary copied to screen, mdlgr_dst in prime position to continue animation
MoveDLGRBinary
; start with auxiliary page
sta PAGE2ON ; start with aux page
start3
ldy #$27 ; start copying
startloop
; reset destination (start at $0400)
mdlgr_resetdst
stz mdlgr_dst ; reset destination self-modifying code
lda #$04
sta mdlgr_dst+1
; start of $04xx-$07xx memory copy (for both aux/main mem) - copy in $0n00-$0n77 chunks
mdlgr_startcopy
ldy #$77 ; init loop counter
; heart of code - copyloop - copy source to destination - self-modifying!
mdlgr_copyloop
mdlgr_src = *+1
lda $5000,y ; load from storage
mdlgr_dst = *+1
sta $0400,y ; save to screen
dey
bpl startloop
bpl mdlgr_copyloop ; continue while positive (do $77 downto $00)
clc ; always add to address for reading after our copy
lda startloop+1
adc #$28 ; increase screen pos
sta startloop+1
lda startloop+2
adc #0
sta startloop+2
; add to source offset
clc
lda mdlgr_src
adc #$80 ; step by $80 (screen pos)
sta mdlgr_src
bcc :cont1
inc mdlgr_src+1 ; remember to do a 16-bit add
:cont1
; add to destination (screen) offset and check if done
clc
lda mdlgr_dst
adc #$80 ; step by $80
sta mdlgr_dst
bcc :cont2
inc mdlgr_dst+1 ; remember to do a 16-bit add
:cont2
lda mdlgr_dst+1 ; a is now the hi byte - remember, our copy only valid from $04-$07
cmp #$08 ; does a=$08 then ? TODO this should be maybe a >= 8
bne mdlgr_startcopy ; not done yet. everything all incremented - branch and continue copy
bit PAGE2 ; is page2 on or off
bpl start4 ; we're on main page - done - continue
; the copy of either aux/main mem complete - check which one
bit PAGE2 ; which page we on?
bpl mdlgr_done ; we're on main page - means we're done
sta PAGE2OFF ; not done, switch to main page, reset, copy, continue
bra start3 ; and continue loop
start4
inc curline ; both aux and main copied - now increase the current line and continue
ldx curline
cpx #24 ; 0-23 done?
beq startdone
lda lgr_lo,x ; get new screen row for writing
sta startloop+4 ; smc
lda lgr_hi,x
sta startloop+5
bra start2
startdone
; not done - flip from aux to main page and do this over again
sta PAGE2OFF ; turn on mainpage
bra mdlgr_resetdst ; play it again sam
; totally done! well...baaaiiiii!
mdlgr_done
rts
curline db 0
; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
; Lo-Res Screen - 40 by 48. 48 = 24 * 2 colors per byte separated by nybble (TTTT BBBB) - one horiz line represented below
; __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
@ -101,7 +130,7 @@ curline db 0
; temp insert directly here
; put gfx40 ; graphics library
put tables ; the tables
; put tables ; the tables
; from Flapple Bird
@ -115,6 +144,7 @@ DL_SetDLRMixMode
;sta C80STOREON
sta $C001
;sta MIXSET
sta $C053
sta $C052
;sta $C053
rts

View File

@ -45,12 +45,14 @@ begin
#success()
do_cmd("mv -f ./main.dsk main.old.dsk", :errchk=>false)
do_cmd("cp ~/m/ProDOS_2_0_3.dsk ./main.dsk")
do_cmd("java -jar ~/m/ac-1.3.5.jar -p main.dsk MAIN BIN 0x7000 < main")
do_cmd("java -jar ~/m/ac-1.3.5.jar -p main.dsk MAIN.SYSTEM BIN 0x2000 < main")
#do_cmd("java -jar ~/m/ac-1.3.5.jar -p main.dsk TD BIN 0x4FFE < td/TD-640X480.DLO")
1.upto(9) do |n|
do_cmd("java -jar ~/m/ac-1.3.5.jar -p main.dsk TD#{n} BIN 0x4FFE < td/TD-#{n}.DLO")
end
do_cmd("java -jar ~/m/ac-1.3.5.jar -p main.dsk TD BIN 0x5000 < trashdove.bin")
# 1.upto(4) do |n|
# do_cmd("java -jar ~/m/ac-1.3.5.jar -p main.dsk TD#{n} BIN 0x5000 < td/tds#{n}.bin")
# end
#do_cmd("java -jar ~/m/ac-1.3.5.jar -p main.dsk TD BIN 0x7FE < td/TD1-SM.SLO")
#do_cmd("java -jar ../ac/ac-1.3.5.jar -p mkmail.dsk GFX BIN 0x7200 < gfx")