diff --git a/megademo/SIZE b/megademo/SIZE index de413c16..507166f6 100644 --- a/megademo/SIZE +++ b/megademo/SIZE @@ -20,6 +20,7 @@ 28217 -- optimize the erase routine in waterfall 28097 -- move takeoff graphics to megademo 28594 -- c64 opener actually works + 28483 -- move falling apple to megademo file Graphics sizes: (LG lores=300B) diff --git a/megademo/falling_apple.s b/megademo/falling_apple.s index 67ecef3f..d5cb622a 100644 --- a/megademo/falling_apple.s +++ b/megademo/falling_apple.s @@ -5,8 +5,8 @@ falling_apple: ;=================== ; init screen - jsr TEXT - jsr HOME +; jsr TEXT +; jsr HOME bit KEYRESET ;=================== @@ -193,9 +193,9 @@ loop2: rts ; 6 -.include "../asm_routines/gr_unrle.s" -.include "gr_copy.s" +;.include "../asm_routines/gr_unrle.s" +;.include "gr_copy.s" -.include "apple_40_96.inc" +;.include "apple_40_96.inc" diff --git a/megademo/gr_unrle.s b/megademo/gr_unrle.s new file mode 100644 index 00000000..51fbf6ce --- /dev/null +++ b/megademo/gr_unrle.s @@ -0,0 +1,115 @@ + ;================= + ; load RLE image + ;================= + ; Output is BASH/BASL + ; Input is in GBASH/GBASL +load_rle_gr: + lda #$0 + tay ; init Y to 0 + sta TEMP ; stores the xcoord + + sta CV ; ycoord=0 + + jsr load_and_increment ; load xsize + sta CH + +rle_loop: + jsr load_and_increment + + cmp #$A1 ; if 0xa1 + beq rle_done ; we are done + + pha + + and #$f0 ; mask + cmp #$a0 ; see if special AX + beq decompress_special + + pla ; note, PLA sets flags! + + ldx #$1 ; only want to print 1 + bne decompress_run + +decompress_special: + pla + + and #$0f ; check if was A0 + + bne decompress_color ; if A0 need to read run, color + +decompress_large: + jsr load_and_increment ; get run length + +decompress_color: + tax ; put runlen into X + jsr load_and_increment ; get color + +decompress_run: +rle_run_loop: + sta (BASL),y ; write out the value + inc BASL ; increment the pointer + bne rle_skip3 ; if wrapped + inc BASH ; then increment the high value + +rle_skip3: + pha ; store colore for later + + inc TEMP ; increment the X value + lda TEMP + cmp CH ; compare against the image width + bcc rle_not_eol ; if less then keep going + + lda BASL ; cheat to avoid a 16-bit add + cmp #$a7 ; we are adding 0x58 to get + bcc rle_add_skip ; to the next line + inc BASH +rle_add_skip: + clc + adc #$58 ; actually do the 0x58 add + sta BASL ; and store it back + + inc CV ; add 2 to ypos + inc CV ; each "line" is two high + + lda CV ; load value + cmp #15 ; if it's greater than 14 it wraps + bcc rle_no_wrap ; Thanks Woz + + lda #$0 ; we wrapped, so set to zero + sta CV + + ; when wrapping have to sub 0x3d8 + sec ; this is a 16-bit subtract routine + lda BASL + sbc #$d8 ; LSB + sta BASL + lda BASH ; MSB + sbc #$3 ; + sta BASH + +rle_no_wrap: + lda #$0 ; set X value back to zero + sta TEMP + +rle_not_eol: + pla ; restore color + dex + bne rle_run_loop ; if not zero, keep looping + beq rle_loop ; and branch always + +rle_done: + lda #$15 ; move the cursor somewhere sane + sta CV + rts + + +load_and_increment: + lda (GBASL),y ; load value ; 5? + inc GBASL ; 5? + bne lskip2 ; 2nt/3 + inc GBASH ; 5? +lskip2: + rts ; 6 + + + diff --git a/megademo/megademo.s b/megademo/megademo.s index 29362d31..6fb7c7e3 100644 --- a/megademo/megademo.s +++ b/megademo/megademo.s @@ -93,6 +93,8 @@ loop_forever: .include "lz4_decode.s" .include "c64_opener.s" .include "falling_apple.s" + .include "gr_unrle.s" + .include "gr_copy.s" .include "starring.s" .include "starring_people.s" .include "check_email.s" @@ -138,6 +140,9 @@ loop_forever: ; No Alignment Needed ;============================ +; falling_apple +.include "apple_40_96.inc" + ; starring .include "starring1.inc" .include "starring2.inc"