gr: boxes

This commit is contained in:
Vince Weaver 2021-01-21 01:32:06 -05:00
parent 5ab04b5cb3
commit 86cb7f5f1c
12 changed files with 623 additions and 0 deletions

View File

@ -1,4 +1,5 @@
all:
cd boxes && make
cd mode7 && make
cd rasterbars && make
cd rotozoom && make
@ -6,6 +7,7 @@ all:
cd starfield && make
clean:
cd boxes && make clean
cd mode7 && make clean
cd rasterbars && make clean
cd rotozoom && make clean

View File

@ -1,5 +1,8 @@
Various experiments in lo-res graphics
+ boxes
makes lores pictures by drawing boxes
+ mode7
mode7 tests, used when making mode7 demo

View File

@ -0,0 +1,38 @@
include ../../../Makefile.inc
DOS33 = ../../../utils/dos33fs-utils/dos33
TOKENIZE = ../../../utils/asoft_basic-utils/tokenize_asoft
LINKERSCRIPTS = ../../../linker_scripts
all: boxes.dsk make_boxes
boxes.dsk: HELLO BOXES
cp empty.dsk boxes.dsk
$(DOS33) -y boxes.dsk SAVE A HELLO
$(DOS33) -y boxes.dsk BSAVE -a 0x300 BOXES
###
HELLO: hello.bas
$(TOKENIZE) < hello.bas > HELLO
###
BOXES: boxes.o
ld65 -o BOXES boxes.o -C $(LINKERSCRIPTS)/apple2_300.inc
boxes.o: boxes.s
ca65 -o boxes.o boxes.s -l boxes.lst
###
make_boxes: make_boxes.o
$(CC) -o make_boxes make_boxes.o $(LFLAGS)
make_boxes.o: make_boxes.c
$(CC) $(CFLAGS) -c make_boxes.c
###
clean:
rm -f *~ *.o *.lst HELLO BOXES make_boxes

30
graphics/gr/boxes/a2.data Normal file
View File

@ -0,0 +1,30 @@
15 0 39 0 47 ; background
8 10 27 1 43 ; monitor back
13 3 20 40 41 ; base bottom
13 3 22 36 39 ; base middle
13 5 23 32 35 ; base top
13 8 24 28 31 ; base tip
8 7 14 35 38 ; keyboard
8 8 18 36 39 ; keyboard
8 13 18 31 31 ; logo
5 3 20 42 43 ; base
5 6 19 44 45 ; base
8 20 23 44 45 ; base brown
8 28 28 8 22 ; monitor back
13 9 24 2 26 ; monitor
8 10 21 4 24 ; bezel
0 11 20 6 23 ; screen
8 34 34 21 41 ; drive side
8 34 36 19 40 ; drive side
5 28 35 19 20 ; drive top
5 27 33 21 22 ; drive top
13 25 33 23 43 ; drive outline
0 26 32 24 32 ; drive 1
0 26 32 34 42 ; drive 2
5 27 32 28 28 ; drive 1 slot
5 27 32 38 38 ; drive 2 slot
3 31 31 31 32 ; drive 1 logo
3 31 31 41 42 ; drive 2 logo
5 29 30 25 30 ; drive 1 door
5 29 30 35 40 ; drive 2 door
12 23 23 2 3 ; monitor power

BIN
graphics/gr/boxes/boxes.dsk Normal file

Binary file not shown.

119
graphics/gr/boxes/boxes.s Normal file
View File

@ -0,0 +1,119 @@
; make pictures by drawing boxes
; 223 -- initial
; 220 -- update end
; 219 -- store color already multiplied by 17
; 215 -- load Y0 directly into X
; 211 -- load X1 directly into H2
; 208 -- add subroutine to read byte into A, no need to save Y
; 205 -- optimize end loop
; 197 -- only update color if changed
.include "zp.inc"
.include "hardware.inc"
X0 = $F0
Y1 = $F3
;1DEFFNP(X)=PEEK(2054+I*5+X)-32:
;GR:POKE49234,0:
;FORI=0TO29:COLOR=FNP(0):FORY=FNP(3)TOFNP(4)
;:HLINFNP(1),FNP(2)ATY:NEXTY,I:GETA
;================================
; Clear screen and setup graphics
;================================
boxes:
jsr SETGR ; set lo-res 40x40 mode
bit FULLGR ; make it 40x48
draw_box_loop:
; get color
jsr load_byte
bmi use_old_color
cmp #$7F
end:
beq end ; hit end
jsr SETCOL
jsr load_byte ; Y0
use_old_color:
and #$3f
tax
jsr load_byte ; Y1
sta Y1
jsr load_byte ; X0
sta X0
jsr load_byte ; X1
sta H2
inner_loop:
;; HLINE Y,H2 at A
;; X left alone, carry set on exit
;; H2 left alone
;; Y and A trashed
ldy X0
txa
jsr HLINE
cpx Y1
inx
bcc inner_loop
bcs draw_box_loop
load_byte:
inc load_byte_smc+1 ; assume we are always < 256 bytes
; so no need to wrap
load_byte_smc:
lda box_data-1
rts
; 4 6 6 6 6
box_data:
.byte $0F,$00,$2F,$00,$27
.byte $08,$01,$2B,$0A,$1B
.byte $0D,$28,$29,$03,$14
.byte $A4,$27,$03,$16
.byte $A0,$23,$05,$17
.byte $9C,$1F,$08,$18
.byte $08,$23,$26,$07,$0E
.byte $A4,$27,$08,$12
.byte $9F,$1F,$0D,$12
.byte $05,$2A,$2B,$03,$14
.byte $AC,$2D,$06,$13
.byte $08,$2C,$2D,$14,$17
.byte $88,$16,$1C,$1C
.byte $0D,$02,$1A,$09,$18
.byte $08,$04,$18,$0A,$15
.byte $00,$06,$17,$0B,$14
.byte $08,$15,$29,$22,$22
.byte $93,$28,$22,$24
.byte $05,$13,$14,$1C,$23
.byte $95,$16,$1B,$21
.byte $0D,$17,$2B,$19,$21
.byte $00,$18,$20,$1A,$20
.byte $A2,$2A,$1A,$20
.byte $05,$1C,$1C,$1B,$20
.byte $A6,$26,$1B,$20
.byte $03,$1F,$20,$1F,$1F
.byte $A9,$2A,$1F,$1F
.byte $05,$19,$1E,$1D,$1E
.byte $A3,$28,$1D,$1E
.byte $0C,$02,$03,$17,$17
.byte $7F

View File

@ -0,0 +1,122 @@
; make pictures by drawing boxes
; 223 -- initial
; 220 -- update end
; 219 -- store color already multiplied by 17
; 215 -- load Y0 directly into X
; 211 -- load X1 directly into H2
.include "zp.inc"
.include "hardware.inc"
X0 = $F0
Y1 = $F3
;1DEFFNP(X)=PEEK(2054+I*5+X)-32:
;GR:POKE49234,0:
;FORI=0TO29:COLOR=FNP(0):FORY=FNP(3)TOFNP(4)
;:HLINFNP(1),FNP(2)ATY:NEXTY,I:GETA
;================================
; Clear screen and setup graphics
;================================
boxes:
jsr SETGR ; set lo-res 40x40 mode
bit FULLGR ; make it 40x48
draw_box_loop:
; get color
jsr load_byte
cmp #$AA
end:
beq end ; hit end
sta COLOR
jsr load_byte
tax
; ldx box_data+1,Y ; Y0
jsr load_byte
; lda box_data+2,Y
sta Y1
jsr load_byte
; lda box_data+3,Y
sta X0
jsr load_byte
; lda box_data+4,Y
sta H2
inner_loop:
tya
pha
;; HLINE Y,H2 at A
;; X left alone, carry set on exit
;; H2 left alone
;; Y and A trashed
ldy X0
txa
jsr HLINE
pla
tay
inx
cpx Y1
beq inner_loop
bcc inner_loop
jmp draw_box_loop
load_byte:
lda box_data
inc load_byte+1 ; assume we are always < 256 bytes
; so no need to wrap
rts
; 4 6 6 6 6
box_data:
.byte $FF,$00,$2F,$00,$27
.byte $88,$01,$2B,$0A,$1B
.byte $DD,$28,$29,$03,$14
.byte $DD,$24,$27,$03,$16
.byte $DD,$20,$23,$05,$17
.byte $DD,$1C,$1F,$08,$18
.byte $88,$23,$26,$07,$0E
.byte $88,$24,$27,$08,$12
.byte $88,$1F,$1F,$0D,$12
.byte $55,$2A,$2B,$03,$14
.byte $55,$2C,$2D,$06,$13
.byte $88,$2C,$2D,$14,$17
.byte $88,$08,$16,$1C,$1C
.byte $DD,$02,$1A,$09,$18
.byte $88,$04,$18,$0A,$15
.byte $00,$06,$17,$0B,$14
.byte $88,$15,$29,$22,$22
.byte $88,$13,$28,$22,$24
.byte $55,$13,$14,$1C,$23
.byte $55,$15,$16,$1B,$21
.byte $DD,$17,$2B,$19,$21
.byte $00,$18,$20,$1A,$20
.byte $00,$22,$2A,$1A,$20
.byte $55,$1C,$1C,$1B,$20
.byte $55,$26,$26,$1B,$20
.byte $33,$1F,$20,$1F,$1F
.byte $33,$29,$2A,$1F,$1F
.byte $55,$19,$1E,$1D,$1E
.byte $55,$23,$28,$1D,$1E
.byte $CC,$02,$03,$17,$17
.byte $AA

BIN
graphics/gr/boxes/empty.dsk Normal file

Binary file not shown.

View File

@ -0,0 +1,103 @@
;; 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
TBCOLOR = $C022 ; IIgs text foreground / background colors
NEWVIDEO = $C029 ; IIgs graphics modes
SPEAKER = $C030
CLOCKCTL = $C034 ; bits 0-3 are IIgs border color
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
PADDLE_BUTTON1 = $C062
PADDL0 = $C064
PTRIG = $C070
;; BASIC ROUTINES
NORMAL = $F273
;; MONITOR ROUTINES
PLOT = $F800 ;; PLOT AT Y,A
PLOT1 = $F80E ;; PLOT at (GBASL),Y (need MASK to be $0f or $f0)
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
GBASCALC= $F847 ;; take Y-coord/2 in A, put address in GBASL/H ( a trashed, C clear)
SETCOL = $F864 ;; COLOR=A
ROM_TEXT2COPY = $F962 ;; iigs
SETTXT = $FB36
SETGR = $FB40
TABV = $FB5B ;; VTAB to A
ROM_MACHINEID = $FBB3 ;; iigs
BELL = $FBDD ;; ring the bell
BASCALC = $FBC1 ;;
VTAB = $FC22 ;; VTAB to CV
HOME = $FC58 ;; Clear the text screen
WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us
CROUT1 = $FD8B
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

View File

@ -0,0 +1,2 @@
5 HOME
10 PRINT CHR$(4);"CATALOG"

View File

@ -0,0 +1,46 @@
#include <stdio.h>
int main(int argc, char **argv) {
char buffer[1024];
char *ptr;
int color,x1,x2,y1,y2;
char output[1024];
int out_ptr=0;
int old_color=0xff;
while(1) {
ptr=fgets(buffer,1024,stdin);
if (ptr==NULL) break;
sscanf(buffer,"%d %d %d %d %d",
&color,&x1,&x2,&y1,&y2);
// printf("\t.byte $%02X,$%02X,$%02X,$%02X,$%02X\n",
// color,x1,x2,y1,y2);
if (color==old_color) {
printf("\t.byte $%02X,$%02X,$%02X,$%02X\n",
y1|0x80,y2,x1,x2);
}
else {
printf("\t.byte $%02X,$%02X,$%02X,$%02X,$%02X\n",
color,y1,y2,x1,x2);
}
old_color=color;
// output[out_ptr]=color+32;
// output[out_ptr+1]=x1+32;
// output[out_ptr+2]=x2+32;
// output[out_ptr+3]=y1+32;
// output[out_ptr+4]=y2+32;
// out_ptr+=5;
}
// output[out_ptr]=0;
// printf("%s\n",output);
printf("\t.byte $FF\n");
return 0;
}

158
graphics/gr/boxes/zp.inc Normal file
View File

@ -0,0 +1,158 @@
;; Zero page monitor routines addresses
;; LZSA addresses
NIBCOUNT = $00
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
; More zero-page addresses
; we try not to conflict with anything DOS, MONITOR or BASIC related
;; Flying Routine Only
TURNING = $60
;SCREEN_X = $61 ; not used?
SCREEN_Y = $62
ANGLE = $63
HORIZ_SCALE_I = $64
HORIZ_SCALE_F = $65
SCALE_I = $64
SCALE_F = $65
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
SPACEY_I = $70
SPACEY_F = $71
CY_I = $72
CY_F = $73
TEMP_I = $74
TEMP_F = $75
DISTANCE_I = $76
DISTANCE_F = $77
SPACEZ_I = $78
SPACEZ_F = $79
DRAW_SPLASH = $7A
SPEED = $7B
SPLASH_COUNT = $7C
OVER_LAND = $7D
NUM1L = $7E
NUM1H = $7F
NUM2L = $80
NUM2H = $81
RESULT = $82 ; 83,84,85
NEGATE = $86 ; UNUSED?
LAST_SPACEX_I = $87
LAST_SPACEY_I = $88
LAST_MAP_COLOR = $89
COLOR_MASK = $8A
;; World Map Only
ODD = $7B
DIRECTION = $7C
REFRESH = $7D
ON_BIRD = $7E
MOVED = $7F
STEPS = $80
TFV_X = $81
TFV_Y = $82
NEWX = $83
NEWY = $84
MAP_X = $85
GROUND_COLOR = $86
LEVEL_OVER = $A0
JOYSTICK_ENABLED= $A1
FRAMEL = $A2
FRAMEH = $A3
WHICH_LOAD = $A4
MENU_RESULT = $A5
SOUND_STATUS = $A6
SOUND_DISABLED = $80
SOUND_IN_LC = $01 ; $01 sound effects in language card
SOUND_MOCKINGBOARD = $02 ; mockingboard detected
JS_BUTTON_STATE = $A7
COLOR1 = $E0
COLOR2 = $E1
MATCH = $E2
XX = $E3
YY = $E4
SHIPY = $E4
YADD = $E5
LOOP = $E6
;MEMPTRL = $E7
;MEMPTRH = $E8
NAMEL = $E9
NAMEH = $EA
NAMEX = $EB
CHAR = $EC
DISP_PAGE = $ED
DRAW_PAGE = $EE
FIRST = $F0
LASTKEY = $F1
PADDLE_STATUS = $F2
XPOS = $F3
YPOS = $F4
TEMP = $FA
RUN = $FA
TEMP2 = $FB
TEMPY = $FB
INL = $FC
INH = $FD
OUTL = $FE
OUTH = $FF
; read any file slot 6 version
; based on FASTLD6 and RTS copyright (c) Peter Ferrie 2011-2013,2018
; modified to assemble with ca65 -- vmw
; added code to patch it to run from current disk slot -- vmw
adrlo = $26 ; constant from boot prom
adrhi = $27 ; constant from boot prom
tmpsec = $3c ; constant from boot prom
reqsec = $3d ; constant from boot prom
sizelo = $44
sizehi = $45
secsize = $46
ldsizel = $70
ldsizeh = $71
namlo = $7b
namhi = $7c
step = $7d ; state for stepper motor
tmptrk = $7e ; temporary copy of current track
phase = $7f ; current phase for /seek