outline2023: hitting the deadline hard...

This commit is contained in:
Vince Weaver 2023-05-18 17:04:33 -04:00
parent 9a9cb955d2
commit 6acaa0d541
7 changed files with 577 additions and 0 deletions

View File

@ -0,0 +1,48 @@
include ../../Makefile.inc
DOS33 = ../../utils/dos33fs-utils/dos33
TOKENIZE = ../../utils/asoft_basic-utils/tokenize_asoft
EMPTYDISK = ../../empty_disk/empty.dsk
LINKERSCRIPTS = ../../linker_scripts/
all: midline.dsk
midline.dsk: HELLO MIDLINE
cp $(EMPTYDISK) midline.dsk
$(DOS33) -y midline.dsk SAVE A HELLO
$(DOS33) -y midline.dsk BSAVE -a 0x6000 MIDLINE
###
submit: midline.zip
midline.zip: MIDLINE midline.s file_id.diz midline.dsk
mkdir -p outline2023_midline
cp MIDLINE ./outline2023_midline
cp midline.s ./outline2023_midline
cp sinetable.s ./outline2023_midline
cp hardware.inc ./outline2023_midline
cp zp.inc ./outline2023_midline
cp file_id.diz ./outline2023_midline
cp midline.dsk ./outline2023_midline
cp midline_720p.mp4 ./outline2023_midline
cp midline_screen.png ./outline2023_midline
zip -r midline.zip outline2023_midline
###
HELLO: hello.bas
$(TOKENIZE) < hello.bas > HELLO
###
MIDLINE: midline.o
ld65 -o MIDLINE midline.o -C $(LINKERSCRIPTS)/apple2_6000.inc
midline.o: midline.s sinetable.s zp.inc hardware.inc
ca65 -o midline.o midline.s -l midline.lst
####
clean:
rm -f *~ *.o *.lst HELLO MIDLINE *.zip

View File

@ -0,0 +1,12 @@
Midline
-
256-byte Intro for Apple IIe, Outline 2023
by Deater / dSr
Cycle-count and midline mode switching
between text, hi-res, and lo-res midscreen.
Only works on Apple IIe models of Apple II
because it uses that model's specific way
of VBLANK detection that doesn't work on
other models

View File

@ -0,0 +1,55 @@
; soft-switches
; yes, I know these aren't necessary the "official" names
KEYBOARD = $C000 ; Read keypress+128
EIGHTYSTOREOFF = $C000 ; (write) turns off 80store
EIGHTYSTOREON = $C001 ; (write) page2 writes to AUX memory
WRMAINRAM = $C004 ; (write)
WRAUXRAM = $C005 ; (write)
CLR80COL = $C00C ; (write)
SET80COL = $C00D ; (write)
CLRMOUSETET = $C00E ; (write) disable moust text
SETMOUSETEXT = $C00F ; (write) enable mouse text
KEYRESET = $C010
VBLANK = $C019 ; *not* RDVBL (VBL signal low) (iie, opposite iigs)
RDVBLBAR = $C019 ; iic
TBCOLOR = $C022 ; IIgs text foreground / background colors
CLOCKCTL = $C034 ; bits 0-3 are IIgs border color
NEWVIDEO = $C029 ; IIgs graphics modes
RDVBLMSK = $C041 ; iic read vbl interrupt
SET_GR = $C050
SET_TEXT= $C051
FULLGR = $C052
TEXTGR = $C053
PAGE1 = $C054
PAGE2 = $C055
LORES = $C056
HIRES = $C057
DISVBL = $C05B ; (write) (iic) (ioudison) disable VBL interrupt
ENVBL = $C05B ; (write) (iic) (ioudison) enable VBL interrupt
CLRAN3 = $C05E ; (write) in 80-col mode, enable double graphics
SETAN3 = $C05F ; (write) in 80-col mode, disable double graphics
PTRIG = $C070 ; analog input reset / reset VBL interrupt (iic)
IOUDISON = $C07E ; (write) disable IOU
IOUDISOFF = $C07F ; (write) enable IOU
; ROM routines
SETCOL = $F864 ; COLOR=A*17
SETGR = $FB40
VLINE = $F828 ; VLINE A,$2D at Y
HGR = $F3E2
HPOSN = $F411
HPLOT0 = $F457 ; plot at (Y,X), (A)
HGLIN = $F53A ; line to (X,A),(Y)
XDRAW0 = $F65D
ROM_TEXT2COPY = $F962 ; iigs
ROM_MACHINEID = $FBB3 ; iigs
COUT = $FDED

View File

@ -0,0 +1,8 @@
5 HOME
10 PRINT " MIDLINE -- 256 BYTES FOR OUTLINE 2023"
15 PRINT " BY DEATER / DSR"
20 PRINT CHR$(4)"CATALOG"
25 PRINT:PRINT "PRESS ANY KEY TO 'BRUN MIDLINE'"
30 GET A$
35 PRINT
40 PRINT CHR$(4)"BRUN MIDLINE"

309
demos/outline2023/midline.s Normal file
View File

@ -0,0 +1,309 @@
; a 256-byte midline demo for Outline 2023
; by Vince `deater` Weaver / dSr
; requires an Apple IIe
.include "zp.inc"
.include "hardware.inc"
; 198 bytes -- proof of concept
; 76 bytes -- optimize Apple II Forever printing code
; 183 bytes -- stable window
; 248 bytes -- sine code added
; 274 bytes -- after much frustration, things sorta working
; 261 bytes -- use zp for sine generation
; 257 bytes -- inline sine generation
; 259 bytes -- fix sine generation initialization, shave some message print
; 247 bytes -- start replacing sather delays with something more compact
; 229 bytes -- finish replacing sather delays
; 228 bytes -- optimize and center the middle area
; 226 bytes -- init some of zero page to zero
; 244 bytes -- switch to hires too
; 247 bytes -- clear HGR
; 264 bytes -- add HGR
; 263 bytes -- better nop
; 263 bytes -- don't init zero page anymore
; 259 bytes -- combine delay_49 routines
; 258 bytes -- init discrete
; GOAL = 256 (Outline 2023 says header doesn't count, is usually 4 on Apple II)
sine = $c00 ; location of sine table
midline:
;================================
; Clear screen and setup graphics
;================================
ldx #0
stx DELTA
stx DELTAH
; setup graphics
sta SETMOUSETEXT ; enable mouse text for Apple char
;==============================
; set up sine table
; X must be 0 when calling
.include "sinetable.s" ; Y is FF after this
; A = 1, X = $40
;====================================================
; setup text page1 screen of "Apple II Forever" text
;====================================================
; X is $40 which is probably OK
; ldx #0
restart:
tay ; reset Y to 0 (or 1 first time through)
inx
beq print_done
print_loop:
lda a2_string,Y
beq restart
jsr COUT ; output char in A to stdout
iny
bne print_loop
print_done:
;===================
; do graphics
jsr HGR ; A and Y=0 now
sta FULLGR
jsr HPLOT0 ; set screen position to X= (y,x) Y=(a)
; saves X,Y,A to zero page
; after Y= orig X/7
; A and X are ??
tiny_loop:
lda #$F6 ; ROT=$F6
tay
tax
dex
jsr XDRAW0 ; XDRAW 1 AT X,Y
; Both A and X are 0 at exit
; Z flag set on exit
; Y varies
dec $0a ; is $4c due to basic
bne tiny_loop ;
;==================================
; get exact vblank region
;==================================
; code by Sather
; "Understanding the Apple IIe"
poll1:
lda VBLANK ; Find end of VBL
bmi poll1 ; Fall through at VBL
poll2:
lda VBLANK
bpl poll2 ; Fall through at VBL' ; 2
lda $00 ;nop3 ; Now slew back in 17029 cycle loops ; 3
lp17029:
; delay 17020
lda #7 ; 2
ldy #96 ; 2
jsr size_delay ; 17012
nop ; 2
nop ; 2
lda VBLANK ; Back to VBL yet? ; 4
nop ; ; 2
bmi lp17029 ; no, slew back ; 2/3
;==============================
; do the cycle counting
;==============================
cycle_start:
;==============================
; top
; 2
top_smc:
ldx #66 ; 2
bne top7 ; bra ; 3/2
top_loop:
pha ; 3
pla ; 4
top7:
; 7
; lda #0 ; 2
; ldy #3 ; 2
; 11
; want to delay 49
jsr delay_49
; jsr size_delay ; 47
; 58
nop ; 2
; 60
dex ; 2
bne top_loop ; 3/2
;===================================
; middle
; -1
ldx #56 ; 2
bne middle_4 ; bra ; 3
middle_loop:
nop ; 2
nop ; 2
middle_4:
; 4
inc $0 ; nop5 ; 5
; 9
jsr delay_16_setgr ; 16
; 25
jsr delay_16_settext ; 16
; 41
jsr delay_16_setgr ; 16
; 57
lda $0 ; nop3 ; 3
; 60
dex ; 2
bne middle_loop ; 3/2
; -1
bottom_smc:
ldx #118 ; 2
bne bottom_4 ; bra ; 3
bottom_loop:
nop ; 2
nop ; 2
; 4
bottom_4:
; 4
; lda #0 ; 2
; ldy #3 ; 2
; 8
; want to delay 50
jsr delay_49
; jsr size_delay ; 47
; 55
lda $0 ; nop3 ; 3
; 58
inx ; 2
cpx #192 ; 2
bcc bottom_loop ; 3/2
; -1
;======================================
; wait 4550 for VBLANK
;======================================
; -1 from before
vblank_start:
; move window
; -1
clc ; 2
lda FRAME ; 3
adc #1 ; 2
sta FRAME ; 3
tay ; save for later ; 2
; 11
lda #0 ; 2
rol ; get carry bit in A ; 2
eor screen_smc+1 ; 4
sta screen_smc+1 ; 4
; 23
screen_smc:
bit LORES ; LORES=C056 HIRES=C057 ; 4
; 27
; FRAME should be in Y
lda sine,Y ; 4 (aligned)
; 31
clc ; 2
adc #2 ; 2
sta top_smc+1 ; 4
adc #56 ; 2
sta bottom_smc+1 ; 4
; 45
; finish delay
; 45
lda #1 ; 2
ldy #241 ; 2
; 49
jsr size_delay ; 4493
; 4542
pha ; 3
pla ; 4
; 4549
jmp cycle_start ; 3
; 4552
; want 4552 here
delay_16_settext:
bit SET_TEXT
rts
delay_16_setgr:
bit SET_GR
rts
delay_49:
lda #0 ; 2
ldy #3 ; 2
;=====================================
; short delay by Bruce Clark
; any delay between 8 to 589832 with res of 9
;=====================================
; 9*(256*A+Y)+8 + 12 for jsr/rts
; A and Y both $FF at the end
size_delay:
delay_loop:
cpy #1
dey
sbc #0
bcs delay_loop
delay_12:
rts
a2_string:
; 012345678901234567 8 9
; .byte "Apple II Forever!! ",'@'+$80," ",0
.byte 'A'+$80,'p'+$80,'p'+$80,'l'+$80,'e'+$80,' '+$80
.byte 'I'+$80,'I'+$80,' '+$80,'F'+$80,'o'+$80,'r'+$80
.byte 'e'+$80,'v'+$80,'e'+$80,'r'+$80,'!'+$80,'!'+$80
.byte ' '+$80,'@'+$00,' '+$80,0

View File

@ -0,0 +1,54 @@
;=================================
; fakes sines based on parabolas
; based on code by White Flame via Cruzer/Camelot
; from codebase64
;=================================
; makes 256 entries, min 0 max 127
; call with X=0!
;DELTA = $2000
;VALUE = $2002
initSineTable:
ldy #$3f
; ldx #$00
; Accumulate the delta (16-bit addition)
init_sine_loop:
value_l_smc:
lda #0
clc
adc DELTA
sta value_l_smc+1
value_h_smc:
lda #0
adc DELTA+1
sta value_h_smc+1
; Reflect the value around for a sine wave
sta sine+$c0,X
sta sine+$80,Y
eor #$7f
sta sine+$40,X
sta sine+$00,Y
; Increase the delta, which creates the
; "acceleration" for a parabola
lda DELTA
adc #$08 ; this value adds up to the proper amplitude
sta DELTA
bcc init_sine_noflo
inc DELTA+1
init_sine_noflo:
; Loop
inx
dey
bpl init_sine_loop
; rts

91
demos/outline2023/zp.inc Normal file
View File

@ -0,0 +1,91 @@
;=========================
; zero page
;=========================
; ZX02 addresses
ZP=$00
offset = ZP+0
ZX0_src = ZP+2
ZX0_dst = ZP+4
bitr = ZP+6
pntr = ZP+7
CH = $24
GBASL = $26
GBASH = $27
BASL = $28
BASH = $29
V2 = $2D
COLOR = $30
; pt3 player
ORNAMENT_L = $60
ORNAMENT_H = $61
SAMPLE_L = $62
SAMPLE_H = $63
LOOP = $64
MB_ADDR_L = $65
MB_ADDR_H = $66
MB_VALUE = $67
DONE_PLAYING = $68
DONE_SONG = $69
PT3_TEMP = $6A
APPLEII_MODEL = $6B
AY_REGISTERS = $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
PT3_MIXER_VAL = $77
A_VOLUME = $78
B_VOLUME = $79
C_VOLUME = $7A
ENVELOPE_FINE = $7B
ENVELOPE_COARSE = $7C
ENVELOPE_SHAPE = $7D
PATTERN_L = $7E
PATTERN_H = $7F
DRAW_PAGE = $8A
SOUND_STATUS = $DE
SOUND_DISABLED = $80
SOUND_IN_LC = $01 ; $01 sound effects in language card
SOUND_MOCKINGBOARD = $02 ; mockingboard detected
HGR_COLLISIONS = $EA
HGRPAGE = $E6
TEMPY = $F0
XX = $F1
FRAME = $F2
FRAMEH = $F3
;VALUE = $F4
;VALUEH = $F5
DELTA = $F6
DELTAH = $F7
YPOS = $FA
TCOLOR = $FB
INL = $FC
INH = $FD
OUTL = $FE
OUTH = $FF