ootw: add another demake

why why why
This commit is contained in:
Vince Weaver 2019-01-13 01:10:44 -05:00
parent 2677930759
commit ac18cfd838
14 changed files with 827 additions and 0 deletions

39
ootw/Makefile Normal file
View File

@ -0,0 +1,39 @@
include ../Makefile.inc
DOS33 = ../dos33fs-utils/dos33
PNG2RLE = ../gr-utils/png2rle
all: ootw.dsk
ootw.dsk: HELLO OOTW
$(DOS33) -y ootw.dsk SAVE A HELLO
$(DOS33) -y ootw.dsk BSAVE -a 0x1000 OOTW
####
OOTW: ootw.o
ld65 -o OOTW ootw.o -C ../linker_scripts/apple2_1000.inc
ootw.o: ootw.s wait_keypress.s \
gr_copy.s gr_fast_clear.s gr_pageflip.s gr_unrle.s \
ootw_backgrounds.inc
ca65 -o ootw.o ootw.s -l ootw.lst
####
HELLO: hello.bas
../asoft_basic-utils/tokenize_asoft < hello.bas > HELLO
#####
ootw_backgrounds.inc: $(PNG2RLE) another.png
$(PNG2RLE) asm another.png planet_rle > ootw_backgrounds.inc
#####
clean:
rm -f *~ *.o *.lst HELLO OOTW

9
ootw/README Normal file
View File

@ -0,0 +1,9 @@
Saw the amazing PICO-8 version of this:
https://liquidream.itch.io/another-world-survival
and thought the lo-res pallette might be just barely enough to do
it justice.
Of course you could just play on your IIgs, but what's the fun in that.

BIN
ootw/another.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 654 B

58
ootw/gr_copy.s Normal file
View File

@ -0,0 +1,58 @@
;=========================================================
; gr_copy_to_current, 40x48 version
;=========================================================
; copy 0xc00 to DRAW_PAGE
;
; 45 + 2 + 120*(8*9 + 5) -1 + 6 = 9292
.align $100
gr_copy_to_current:
lda DRAW_PAGE ; 3
clc ; 2
adc #$4 ; 2
sta gr_copy_line+5 ; 4
sta gr_copy_line+11 ; 4
adc #$1 ; 2
sta gr_copy_line+17 ; 4
sta gr_copy_line+23 ; 4
adc #$1 ; 2
sta gr_copy_line+29 ; 4
sta gr_copy_line+35 ; 4
adc #$1 ; 2
sta gr_copy_line+41 ; 4
sta gr_copy_line+47 ; 4
;===========
; 45
ldy #119 ; for early ones, copy 120 bytes ; 2
gr_copy_line:
lda $C00,Y ; load a byte (self modified) ; 4
sta $400,Y ; store a byte (self modified) ; 5
lda $C80,Y ; load a byte (self modified) ; 4
sta $480,Y ; store a byte (self modified) ; 5
lda $D00,Y ; load a byte (self modified) ; 4
sta $500,Y ; store a byte (self modified) ; 5
lda $D80,Y ; load a byte (self modified) ; 4
sta $580,Y ; store a byte (self modified) ; 5
lda $E00,Y ; load a byte (self modified) ; 4
sta $600,Y ; store a byte (self modified) ; 5
lda $E80,Y ; load a byte (self modified) ; 4
sta $680,Y ; store a byte (self modified) ; 5
lda $F00,Y ; load a byte (self modified) ; 4
sta $700,Y ; store a byte (self modified) ; 5
lda $F80,Y ; load a byte (self modified) ; 4
sta $780,Y ; store a byte (self modified) ; 5
dey ; decrement pointer ; 2
bpl gr_copy_line ; ; 2nt/3
rts ; 6

192
ootw/gr_fast_clear.s Normal file
View File

@ -0,0 +1,192 @@
clear_screens:
;===================================
; Clear top/bottom of page 0
;===================================
lda #$0
sta DRAW_PAGE
jsr clear_top
jsr clear_bottom
;===================================
; Clear top/bottom of page 1
;===================================
lda #$4
sta DRAW_PAGE
jsr clear_top
jsr clear_bottom
rts
clear_bottoms:
;===================================
; Clear bottom of page 0
;===================================
lda #$0
sta DRAW_PAGE
jsr clear_bottom
;===================================
; Clear bottom of page 1
;===================================
lda #$4
sta DRAW_PAGE
jsr clear_bottom
rts
;=========================================================
; clear_top
;=========================================================
; clear DRAW_PAGE
; original = 14,558 cycles(?) 15ms, 70Hz
; OPTIMIZED MAX (page0,48rows): 45*120+4+6 = 5410 = 5.4ms 185Hz
; (pageX,40rows): 50*120+4+6 = 6010 = 6.0ms 166Hz
; 50*120+4+6+37 = 6055 = 6.0ms 166Hz
clear_top:
lda #0 ; 2
clear_top_a:
sta COLOR ; 3
clc ; 2
lda DRAW_PAGE ; 3
adc #4 ; 2
sta __ctf+2 ; 3
sta __ctf+5 ; 3
adc #1 ; 2
sta __ctf+8 ; 3
sta __ctf+11 ; 3
adc #1 ; 2
sta __ctf2+2 ; 3
sta __ctf2+5 ; 3
adc #1 ; 2
sta __ctf2+8 ; 3
sta __ctf2+11 ; 3
ldy #120 ; 2
lda COLOR ; 3
clear_top_fast_loop:
__ctf:
sta $400,Y ; 5
sta $480,Y ; 5
sta $500,Y ; 5
sta $580,Y ; 5
cpy #80 ; 2
bpl no_draw_bottom ; 2nt/3
__ctf2:
sta $600,Y ; 5
sta $680,Y ; 5
sta $700,Y ; 5
sta $780,Y ; 5
no_draw_bottom:
dey ; 2
bpl clear_top_fast_loop ; 2nt/3
rts ; 6
;=========================================================
; clear_bottom
;=========================================================
; clear bottom of draw page
clear_bottom:
clc ; 2
lda DRAW_PAGE ; 3
adc #6 ; 2
sta __cbf2+2 ; 3
sta __cbf2+5 ; 3
adc #1 ; 2
sta __cbf2+8 ; 3
sta __cbf2+11 ; 3
ldy #120 ; 2
lda #$a0 ; Normal Space ; 2
clear_bottom_fast_loop:
__cbf2:
sta $600,Y ; 5
sta $680,Y ; 5
sta $700,Y ; 5
sta $780,Y ; 5
dey ; 2
cpy #80 ; 2
bpl clear_bottom_fast_loop ; 2nt/3
rts ; 6
clear_screens_notext:
;===================================
; Clear top/bottom of page 0
;===================================
lda #$0
sta DRAW_PAGE
jsr clear_all
;===================================
; Clear top/bottom of page 1
;===================================
lda #$4
sta DRAW_PAGE
jsr clear_all
rts
;=========================================================
; clear_all
;=========================================================
; clear 48 rows
clear_all:
clc ; 2
lda DRAW_PAGE ; 3
adc #4 ; 2
sta __caf+2 ; 3
sta __caf+5 ; 3
adc #1 ; 2
sta __caf+8 ; 3
sta __caf+11 ; 3
adc #1 ; 2
sta __caf2+2 ; 3
sta __caf2+5 ; 3
adc #1 ; 2
sta __caf2+8 ; 3
sta __caf2+11 ; 3
ldy #120 ; 2
clear_all_color:
lda #0 ; 2
clear_all_fast_loop:
__caf:
sta $400,Y ; 5
sta $480,Y ; 5
sta $500,Y ; 5
sta $580,Y ; 5
__caf2:
sta $600,Y ; 5
sta $680,Y ; 5
sta $700,Y ; 5
sta $780,Y ; 5
dey ; 2
bpl clear_all_fast_loop ; 2nt/3
rts ; 6

24
ootw/gr_pageflip.s Normal file
View File

@ -0,0 +1,24 @@
;==========
; page_flip
;==========
page_flip:
lda DISP_PAGE ; 3
beq page_flip_show_1 ; 2nt/3
page_flip_show_0:
bit PAGE0 ; 4
lda #4 ; 2
sta DRAW_PAGE ; DRAW_PAGE=1 ; 3
lda #0 ; 2
sta DISP_PAGE ; DISP_PAGE=0 ; 3
rts ; 6
page_flip_show_1:
bit PAGE1 ; 4
sta DRAW_PAGE ; DRAW_PAGE=0 ; 3
lda #1 ; 2
sta DISP_PAGE ; DISP_PAGE=1 ; 3
rts ; 6
;====================
; DISP_PAGE=0 26
; DISP_PAGE=1 24

115
ootw/gr_unrle.s Normal file
View File

@ -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

84
ootw/hardware.inc Normal file
View File

@ -0,0 +1,84 @@
;; HARDWARE LOCATIONS
KEYPRESS = $C000
KEYRESET = $C010
;; SOFT SWITCHES
CLR80COL = $C000 ; PAGE0/PAGE1 normal
SET80COL = $C001 ; PAGE0/PAGE1 switches PAGE0 in Aux instead
EIGHTYCOLOFF = $C00C
EIGHTYCOLON = $C00D
SPEAKER = $C030
SET_GR = $C050
SET_TEXT = $C051
FULLGR = $C052
TEXTGR = $C053
PAGE0 = $C054
PAGE1 = $C055
LORES = $C056 ; Enable LORES graphics
HIRES = $C057 ; Enable HIRES graphics
AN3 = $C05E ; Annunciator 3
PADDLE_BUTTON0 = $C061
PADDL0 = $C064
PTRIG = $C070
;; BASIC ROUTINES
NORMAL = $F273
;; MONITOR ROUTINES
HLINE = $F819 ;; HLINE Y,$2C at A
VLINE = $F828 ;; VLINE A,$2D at Y
CLRSCR = $F832 ;; Clear low-res screen
CLRTOP = $F836 ;; clear only top of low-res screen
SETCOL = $F864 ;; COLOR=A
TEXT = $FB36
TABV = $FB5B ;; VTAB to A
BASCALC = $FBC1 ;;
VTAB = $FC22 ;; VTAB to CV
HOME = $FC58 ;; Clear the text screen
WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us
SETINV = $FE80 ;; INVERSE
SETNORM = $FE84 ;; NORMAL
COUT = $FDED ;; output A to screen
COUT1 = $FDF0 ;; output A to screen
COLOR_BLACK = 0
COLOR_RED = 1
COLOR_DARKBLUE = 2
COLOR_PURPLE = 3
COLOR_DARKGREEN = 4
COLOR_GREY = 5
COLOR_MEDIUMBLUE = 6
COLOR_LIGHTBLUE = 7
COLOR_BROWN = 8
COLOR_ORANGE = 9
COLOR_GREY2 = 10
COLOR_PINK = 11
COLOR_LIGHTGREEN = 12
COLOR_YELLOW = 13
COLOR_AQUA = 14
COLOR_WHITE = 15
COLOR_BOTH_BLACK = $00
COLOR_BOTH_RED = $11
COLOR_BOTH_DARKBLUE = $22
COLOR_BOTH_DARKGREEN = $44
COLOR_BOTH_GREY = $55
COLOR_BOTH_MEDIUMBLUE = $66
COLOR_BOTH_LIGHTBLUE = $77
COLOR_BOTH_BROWN = $88
COLOR_BOTH_ORANGE = $99
COLOR_BOTH_PINK = $BB
COLOR_BOTH_LIGHTGREEN = $CC
COLOR_BOTH_YELLOW = $DD
COLOR_BOTH_AQUA = $EE
COLOR_BOTH_WHITE = $FF

5
ootw/hello.bas Normal file
View File

@ -0,0 +1,5 @@
5 HOME
10 PRINT "OOTW V0.1 BY DEATER"
20 PRINT:PRINT
100 PRINT CHR$ (4)"BRUN OOTW"

BIN
ootw/ootw.dsk Normal file

Binary file not shown.

78
ootw/ootw.s Normal file
View File

@ -0,0 +1,78 @@
; Ootw
.include "zp.inc"
.include "hardware.inc"
title_screen:
;===========================
; Enable graphics
bit LORES
bit SET_GR
bit FULLGR
;===========================
; Clear both bottoms
lda #$4
sta DRAW_PAGE
jsr clear_bottom
lda #$0
sta DRAW_PAGE
jsr clear_bottom
lda #0
sta DRAW_PAGE
lda #1
sta DISP_PAGE
;=============================
; Load title_rle
lda #$0c
sta BASH
lda #$00
sta BASL ; load image off-screen 0xc00
lda #>(planet_rle)
sta GBASH
lda #<(planet_rle)
sta GBASL
jsr load_rle_gr
;=================================
; copy to both pages
jsr gr_copy_to_current
jsr page_flip
jsr gr_copy_to_current
lda #20
sta YPOS
lda #20
sta XPOS
;=================================
; wait for keypress
forever:
jsr wait_until_keypress
; jsr TEXT
jsr page_flip
jmp forever
.include "wait_keypress.s"
.include "gr_pageflip.s"
.include "gr_unrle.s"
.include "gr_fast_clear.s"
.include "gr_copy.s"
.include "ootw_backgrounds.inc"

50
ootw/ootw_backgrounds.inc Normal file
View File

@ -0,0 +1,50 @@
planet_rle: .byte $28 ; ysize=48
.byte $22,$22, $99, $A9,$66, $76, $77, $76, $AD,$66
.byte $67, $AB,$66, $88, $22, $29, $86, $A6,$66
.byte $76, $A3,$66, $7F, $76, $AE,$66, $67, $66
.byte $76, $A7,$66, $22, $89, $22, $28, $96
.byte $A4,$66, $77, $A4,$66, $67, $7F, $A0,$13,$66, $76
.byte $A4,$66, $22, $28, $22,$22, $99, $A5,$66, $67
.byte $A3,$66, $76, $77, $A0,$15,$66, $76, $66,$66, $A4,$22
.byte $89, $26, $A8,$66, $7F, $66, $76, $A0,$11,$66
.byte $16, $00, $06, $66,$66, $67, $22, $88
.byte $22,$22, $88, $22, $99, $A5,$66, $67,$67, $66,$66
.byte $22, $89, $96, $66, $76, $AD,$66, $A4,$00
.byte $66,$66, $22,$22, $28, $88, $89, $22,$22, $A9,$66
.byte $22, $88,$88, $A3,$66, $67, $66, $67, $66
.byte $67, $66,$66, $76, $66, $76, $A3,$66, $00
.byte $60,$60, $06, $66, $22,$22, $82, $22, $82
.byte $28, $22, $A9,$66, $82, $88,$88, $66, $87
.byte $A6,$66, $55, $96, $A4,$66, $67, $28, $A5,$88
.byte $22,$22, $28, $22, $28, $82, $22, $76
.byte $66, $76, $66,$66, $96, $A3,$66, $A3,$88, $66
.byte $88, $A5,$66, $86, $55, $59, $A5,$66, $62
.byte $A5,$28, $A5,$22, $88, $22, $82,$82, $66,$66, $67
.byte $55, $66, $67, $26, $88,$88, $29, $66
.byte $88, $66, $76, $66, $76, $66, $65
.byte $55, $95, $76, $A5,$66, $88,$88, $82, $22
.byte $88, $22, $88, $A7,$22, $A3,$66, $55, $66,$66
.byte $22, $88,$88, $22, $66, $88, $A5,$66, $58
.byte $55,$55, $66,$66, $67, $66,$66, $22, $A3,$88, $22
.byte $88, $22,$22, $28, $82, $A3,$22, $88, $82
.byte $28, $86, $A3,$55, $56, $52, $28, $88
.byte $22, $56, $88, $96,$96, $56,$56, $A3,$55, $85
.byte $55,$55, $56, $26, $A3,$82, $88, $22, $88,$88
.byte $A3,$22, $88, $A3,$22, $28, $22,$22, $28,$28, $55,$55
.byte $22, $25, $22, $88, $82, $85, $88
.byte $99, $BB, $A4,$55, $85, $88, $55,$55, $25
.byte $82, $A4,$88, $82,$82, $88, $A3,$22, $28, $A8,$22
.byte $25, $A4,$82, $A4,$88, $0B, $A5,$85, $88,$88, $85,$85
.byte $82, $A8,$88, $A4,$22, $52, $82, $55, $85
.byte $AA,$25, $28, $25,$25, $BB, $25,$25, $28, $A8,$25
.byte $85, $55,$55, $A4,$85, $22, $55, $88, $55,$55
.byte $00, $28, $AE,$22, $BB, $AC,$22, $28, $85
.byte $55, $A3,$88, $A3,$55, $25, $58, $50, $02
.byte $A5,$52, $72, $A3,$52, $22, $52,$52, $72, $52
.byte $44, $A6,$52, $22, $A6,$52, $72, $55, $52
.byte $55, $58, $A3,$82, $88, $82,$82, $00, $88,$88
.byte $A7,$82, $88, $A3,$82, $88, $44, $A6,$82, $88
.byte $A4,$82, $88, $A6,$82, $A5,$88, $08, $00, $88
.byte $08, $AC,$88, $F4, $F8, $A0,$11,$88, $A6,$28, $00
.byte $28, $00, $28, $A4,$22, $A0,$1A,$28, $A0,$A0,$00
.byte $A1

5
ootw/wait_keypress.s Normal file
View File

@ -0,0 +1,5 @@
wait_until_keypress:
lda KEYPRESS ; 4
bpl wait_until_keypress ; 3
bit KEYRESET ; clear the keyboard buffer
rts ; 6

168
ootw/zp.inc Normal file
View File

@ -0,0 +1,168 @@
;; Zero Page
FRAMEBUFFER = $00 ; $00 - $0F
;; LZ4 addresses
LZ4_SRC = $00
LZ4_DST = $02
LZ4_END = $04
COUNT = $06
DELTA = $08
;; Zero page monitor routines addresses
WNDLFT = $20
WNDWDTH = $21
WNDTOP = $22
WNDBTM = $23
CH = $24
CV = $25
GBASL = $26
GBASH = $27
BASL = $28
BASH = $29
H2 = $2C
V2 = $2D
MASK = $2E
COLOR = $30
;INVFLG = $32
; dos33 zero page = 26-2f, 35-38, 3e 3f 40-4d
; overlap applesoft 67-6a,6f,70,af,b0,ca-cd,d8
; DOS33: Confirmed kills $68
RWTSL = $60
RWTSH = $61
DOSBUFL = $62
DOSBUFH = $63
FILEML = $64
FILEMH = $65
FRAME = $60
FRAMEH = $61
WAITING = $62
LETTERL = $63
LETTERH = $64
LETTERX = $65
LETTERY = $66
LETTERD = $67
LETTER = $68
BLARGH = $69
;FACTOR_I = $66
;FACTOR_F = $67
;DX_I = $68
;DX_F = $69
;SPACEX_I = $6A
;SPACEX_F = $6B
;CX_I = $6C
;CX_F = $6D
;DY_I = $6E
;DY_F = $6F
ZPOS = $78
REGISTER_DUMP = $70
A_FINE_TONE = $70
A_COARSE_TONE = $71
B_FINE_TONE = $72
B_COARSE_TONE = $73
C_FINE_TONE = $74
C_COARSE_TONE = $75
NOISE = $76
ENABLE = $77
A_VOLUME = $78
B_VOLUME = $79
C_VOLUME = $7A
ENVELOPE_FINE = $7B
ENVELOPE_COARSE = $7C
ENVELOPE_SHAPE = $7D
COPY_OFFSET = $7E
DECODER_STATE = $7F
REGISTER_DUMP2 = $80
A_FINE_TONE2 = $80
A_COARSE_TONE2 = $81
B_FINE_TONE2 = $82
B_COARSE_TONE2 = $83
C_FINE_TONE2 = $84
C_COARSE_TONE2 = $85
NOISE2 = $86
ENABLE2 = $87
A_VOLUME2 = $88
B_VOLUME2 = $89
C_VOLUME2 = $8A
ENVELOPE_FINE2 = $8B
ENVELOPE_COARS2 = $8C
ENVELOPE_SHAPE2 = $8D
LYRICSL = $8E
LYRICSH = $8F
FRAME_COUNT = $90
MB_VALUE = $91
MB_ADDRL = $91
MB_ADDRH = $92
DONE_PLAYING = $93
MB_CHUNK_OFFSET = $94
MB_FRAME = $94
MB_PATTERN = $95
CHUNKSIZE = $95
LZ4_DONE = $96
DECODE_ERROR = $97
COPY_TIME = $98
DECOMPRESS_TIME = $99
TIME_TAKEN = $9A
LYRICS_ACTIVE = $9B
;FORTYCOL = $9C
CURSOR = $9D
; More zero-page addresses
; we try not to conflict with anything DOS, MONITOR or BASIC related
;COLOR1 = $E0
;COLOR2 = $E1
;MATCH = $E2
XX = $E3
YY = $E4
HGR_COLOR = $E4
;SHIPY = $E4
;YADD = $E5
;LOOP = $E6
;MEMPTRL = $E7
;MEMPTRH = $E8
;NAMEL = $E9
;NAMEH = $EA
;NAMEX = $EB
;CHAR = $EC
STATE = $ED
DISP_PAGE = $ED
DRAW_PAGE = $EE
OFFSET = $EF
;FIRST = $F0
LASTKEY = $F1
PADDLE_STATUS = $F2
SPRITETEMP = $F2
XPOS = $F3
YPOS = $F4
TEMP = $FA
TEMPY = $FB
INL = $FC
INH = $FD
OUTL = $FE
OUTH = $FF