graphics: bitmap loader

can't seem to get beyond 16x14 or so
This commit is contained in:
Vince Weaver 2021-03-15 15:23:39 -04:00
parent 08c9e7e90e
commit 66cdd48dbe
11 changed files with 716 additions and 0 deletions

View File

@ -0,0 +1,46 @@
include ../../../Makefile.inc
DOS33 = ../../../utils/dos33fs-utils/dos33
TOKENIZE = ../../../utils/asoft_basic-utils/tokenize_asoft
LINKERSCRIPTS = ../../../linker_scripts
EMPTYDISK = ../../../empty_disk/empty.dsk
all: bitmap.dsk make_bitmap
bitmap.dsk: HELLO EYE EYE.BAS
cp $(EMPTYDISK) bitmap.dsk
$(DOS33) -y bitmap.dsk SAVE A HELLO
$(DOS33) -y bitmap.dsk SAVE A EYE.BAS
$(DOS33) -y bitmap.dsk BSAVE -a 0xC00 EYE
###
HELLO: hello.bas
$(TOKENIZE) < hello.bas > HELLO
###
EYE.BAS: eye.bas
$(TOKENIZE) < eye.bas > EYE.BAS
###
EYE: eye.o
ld65 -o EYE eye.o -C $(LINKERSCRIPTS)/apple2_c00.inc
eye.o: eye.s
ca65 -o eye.o eye.s -l eye.lst
###
make_bitmap: make_bitmap.o
$(CC) -o make_bitmap make_bitmap.o $(LFLAGS)
make_bitmap.o: make_bitmap.c
$(CC) $(CFLAGS) -c make_bitmap.c
###
clean:
rm -f *~ *.o *.lst HELLO EYE EYE.BAS make_bitmap

View File

@ -0,0 +1,81 @@
; Bitmap test
; by Vince `deater` Weaver <vince@deater.net>
; eye image by (TODO) from lovebyte 16x16 compo
; 291 -- initial code
; 183 -- draw top/bottom nibble
; 182 -- end loop branch not jmp
; 179 -- make YPOS in memory
; 178 -- move end handling around
; 175 -- use SCRN2
; 171 -- alternate carry
; 168 -- realize SETCOL leaves result in A
.include "zp.inc"
.include "hardware.inc"
;================================
; Clear screen and setup graphics
;================================
eye:
jsr SETGR ; set lo-res 40x40 mode
; A=$D0 afterward
ldx #$ff ; beginning of data
draw_eye_yloop:
ypos_smc:
lda #4 ; YPOS
; take Y-coord/2 in A, put address in GBASL/H ( a trashed, C clear)
jsr GBASCALC
ldy #12
draw_eye_xloop:
; draw bottom nibble first
tya
ror ; get odd or even in carry
bcs plot_it ; only increment X every other
inx
end:
bmi end ; if X hits 128, done
plot_it:
lda eye_data,X ; get color
jsr SCRN2 ; put top or bottom nibble in A based on C
jsr SETCOL ; duplicate color in top/bottom
sta (GBASL),Y ; plot double high color
iny
cpy #28
bne draw_eye_xloop
inc ypos_smc+1
bne draw_eye_yloop ; branch always
eye_data:
.byte $BB,$88,$BB,$0B,$08,$88,$80,$B0
.byte $8B,$B8,$0B,$08,$00,$00,$00,$00
.byte $88,$0B,$08,$00,$00,$00,$00,$00
.byte $B8,$08,$00,$00,$44,$04,$00,$00
.byte $8B,$00,$40,$44,$F7,$7F,$04,$00
.byte $08,$40,$4C,$00,$75,$FF,$47,$70
.byte $00,$C4,$04,$00,$50,$F7,$4F,$70
.byte $00,$44,$0C,$00,$00,$F7,$4F,$F0
.byte $07,$C4,$04,$00,$00,$75,$47,$F0
.byte $0F,$44,$0C,$00,$00,$40,$44,$F0
.byte $7F,$40,$4C,$00,$00,$C4,$04,$F7
.byte $FF,$40,$C4,$4C,$4C,$4C,$04,$FF
.byte $F7,$07,$44,$C4,$C4,$44,$70,$FF
.byte $78,$7F,$00,$44,$44,$00,$F7,$7F
.byte $8B,$87,$7F,$00,$00,$F7,$7F,$88
.byte $BB,$8B,$88,$88,$88,$88,$88,$BB

View File

@ -0,0 +1,5 @@
1GR
2C=4*PEEK(2166+I)-192+(PEEK(2278+I/3)-35)/4^(I-INT(I/3)*3)
3FORX=XTOX+1:COLOR=C:PLOTX,I/8:C=C/16:NEXT:X=X*(X<15):I=I+1:GOTO2
4"RO^22RDYR[22000$O2200000^200A1$-R0@AjO102@?/MlAL0a1$AmCL0A30!jCi1a100JAl3A300@5iO@C00a1jo@aCC7.oj1AaaAIoNO0A5-mOV&S/#S####S#2#32#S&#_/#0&#S##2#S2#/&S

View File

@ -0,0 +1,16 @@
.byte $BB,$88,$BB,$0B,$08,$88,$80,$B0
.byte $8B,$B8,$0B,$08,$00,$00,$00,$00
.byte $88,$0B,$08,$00,$00,$00,$00,$00
.byte $B8,$08,$00,$00,$44,$04,$00,$00
.byte $8B,$00,$40,$44,$F7,$7F,$04,$00
.byte $08,$40,$4C,$00,$75,$FF,$47,$70
.byte $00,$C4,$04,$00,$50,$F7,$4F,$70
.byte $00,$44,$0C,$00,$00,$F7,$4F,$F0
.byte $07,$C4,$04,$00,$00,$75,$47,$F0
.byte $0F,$44,$0C,$00,$00,$40,$44,$F0
.byte $7F,$40,$4C,$00,$00,$C4,$04,$F7
.byte $FF,$40,$C4,$4C,$4C,$4C,$04,$FF
.byte $F7,$07,$44,$C4,$C4,$44,$70,$FF
.byte $78,$7F,$00,$44,$44,$00,$F7,$7F
.byte $8B,$87,$7F,$00,$00,$F7,$7F,$88
.byte $BB,$8B,$88,$88,$88,$88,$88,$BB

View File

@ -0,0 +1,15 @@
.byte $BB,$88,$BB,$0B,$08,$88,$80,$B0
.byte $8B,$B8,$0B,$08,$00,$00,$00,$00
.byte $88,$0B,$08,$00,$00,$00,$00,$00
.byte $B8,$08,$00,$00,$44,$04,$00,$00
.byte $8B,$00,$40,$44,$F7,$7F,$04,$00
.byte $08,$40,$4C,$00,$75,$FF,$47,$70
.byte $00,$C4,$04,$00,$50,$F7,$4F,$70
.byte $00,$44,$0C,$00,$00,$F7,$4F,$F0
.byte $07,$C4,$04,$00,$00,$75,$47,$F0
.byte $0F,$44,$0C,$00,$00,$40,$44,$F0
.byte $7F,$40,$4C,$00,$00,$C4,$04,$F7
.byte $FF,$40,$C4,$4C,$4C,$4C,$04,$FF
.byte $F7,$07,$44,$C4,$C4,$44,$70,$FF
.byte $78,$7F,$00,$44,$44,$00,$F7,$7F

79
graphics/gr/bitmap/eye.s Normal file
View File

@ -0,0 +1,79 @@
; Bitmap test
; by Vince `deater` Weaver <vince@deater.net>
; eye image by LDX - LamerDeluxe from lovebyte 16x16 compo
; 291 -- initial code
; 183 -- draw top/bottom nibble
; 182 -- end loop branch not jmp
; 179 -- make YPOS in memory
; 178 -- move end handling around
; 175 -- use SCRN2
; 171 -- alternate carry
; 168 -- realize SETCOL leaves result in A
; 166 -- half-height
.include "zp.inc"
.include "hardware.inc"
;================================
; Clear screen and setup graphics
;================================
eye:
jsr SETGR ; set lo-res 40x40 mode
; A=$D0 afterward
ldx #$ff ; beginning of data
draw_eye_yloop:
ldy #12
draw_eye_xloop:
; draw bottom nibble first
tya
ror ; get odd or even in carry
bcs plot_it ; only increment X every other
inx
end:
bmi end ; if X hits 128, done
plot_it:
lda eye_data,X ; get color
jsr SCRN2 ; put top or bottom nibble in A based on C
jsr SETCOL ; duplicate color in top/bottom
ypos_smc:
lda #16 ; YPOS (center downward)
jsr PLOT
iny
cpy #28
bne draw_eye_xloop
inc ypos_smc+1
bne draw_eye_yloop ; branch always
eye_data:
.byte $BB,$88,$BB,$0B,$08,$88,$80,$B0
.byte $8B,$B8,$0B,$08,$00,$00,$00,$00
.byte $88,$0B,$08,$00,$00,$00,$00,$00
.byte $B8,$08,$00,$00,$44,$04,$00,$00
.byte $8B,$00,$40,$44,$F7,$7F,$04,$00
.byte $08,$40,$4C,$00,$75,$FF,$47,$70
.byte $00,$C4,$04,$00,$50,$F7,$4F,$70
.byte $00,$44,$0C,$00,$00,$F7,$4F,$F0
.byte $07,$C4,$04,$00,$00,$75,$47,$F0
.byte $0F,$44,$0C,$00,$00,$40,$44,$F0
.byte $7F,$40,$4C,$00,$00,$C4,$04,$F7
.byte $FF,$40,$C4,$4C,$4C,$4C,$04,$FF
.byte $F7,$07,$44,$C4,$C4,$44,$70,$FF
.byte $78,$7F,$00,$44,$44,$00,$F7,$7F
.byte $8B,$87,$7F,$00,$00,$F7,$7F,$88
.byte $BB,$8B,$88,$88,$88,$88,$88,$BB

View File

@ -0,0 +1,81 @@
; Bitmap test
; by Vince `deater` Weaver <vince@deater.net>
; eye image by (TODO) from lovebyte 16x16 compo
; 291 -- initial code
; 183 -- draw top/bottom nibble
; 182 -- end loop branch not jmp
; 179 -- make YPOS in memory
; 178 -- move end handling around
; 175 -- use SCRN2
; 171 -- alternate carry
; 168 -- realize SETCOL leaves result in A
.include "zp.inc"
.include "hardware.inc"
;================================
; Clear screen and setup graphics
;================================
eye:
jsr SETGR ; set lo-res 40x40 mode
; A=$D0 afterward
ldx #$ff ; beginning of data
draw_eye_yloop:
ypos_smc:
lda #4 ; YPOS
; take Y-coord/2 in A, put address in GBASL/H ( a trashed, C clear)
jsr GBASCALC
ldy #12
draw_eye_xloop:
; draw bottom nibble first
tya
ror ; get odd or even in carry
bcs plot_it ; only increment X every other
inx
end:
bmi end ; if X hits 128, done
plot_it:
lda eye_data,X ; get color
jsr SCRN2 ; put top or bottom nibble in A based on C
jsr SETCOL ; duplicate color in top/bottom
sta (GBASL),Y ; plot double high color
iny
cpy #28
bne draw_eye_xloop
inc ypos_smc+1
bne draw_eye_yloop ; branch always
eye_data:
.byte $BB,$88,$BB,$0B,$08,$88,$80,$B0
.byte $8B,$B8,$0B,$08,$00,$00,$00,$00
.byte $88,$0B,$08,$00,$00,$00,$00,$00
.byte $B8,$08,$00,$00,$44,$04,$00,$00
.byte $8B,$00,$40,$44,$F7,$7F,$04,$00
.byte $08,$40,$4C,$00,$75,$FF,$47,$70
.byte $00,$C4,$04,$00,$50,$F7,$4F,$70
.byte $00,$44,$0C,$00,$00,$F7,$4F,$F0
.byte $07,$C4,$04,$00,$00,$75,$47,$F0
.byte $0F,$44,$0C,$00,$00,$40,$44,$F0
.byte $7F,$40,$4C,$00,$00,$C4,$04,$F7
.byte $FF,$40,$C4,$4C,$4C,$4C,$04,$FF
.byte $F7,$07,$44,$C4,$C4,$44,$70,$FF
.byte $78,$7F,$00,$44,$44,$00,$F7,$7F
.byte $8B,$87,$7F,$00,$00,$F7,$7F,$88
.byte $BB,$8B,$88,$88,$88,$88,$88,$BB

View File

@ -0,0 +1,104 @@
;; 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)
SCRN2 = $F879 ;; set A to top or bottom nibble based on C
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 ;; A is $D0 after
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,129 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#define OFFSET 32
#define OFFSET2 35
//#define OFFSET 35
static int hex2int(int val) {
if ((val>='0') && (val<='9')) return val-'0';
if ((val>='A') && (val<='F')) return (val-'A')+10;
if ((val>='a') && (val<='f')) return (val-'a')+10;
printf("Unknown: %c %d\n",val,val);
return -1;
}
int main(int argc, char **argv) {
int i = 0;
int e = 0,filesize;
int val,pv,final;
unsigned char in[1024];
unsigned char enc[1024],enc2[1024];
int third,enc_ptr=0;
char string[256];
char *result;
int op=0;
memset(in,0,sizeof(in));
while(1) {
result=fgets(string,256,stdin);
if (result==NULL) break;
for(i=0;i<strlen(string);i++) {
if (string[i]=='$') {
in[op]=(hex2int(string[i+1])<<4)+hex2int(string[i+2]);
op++;
}
}
}
filesize=op;
i=0;
do {
third = ((in[i + 2] & 3) << 4) +
((in[i + 1] & 3) << 2) + (in[i + 0] & 3);
enc[e++]=third+OFFSET2;
if (i<filesize) {
val=in[i+0];
pv=val;
val=val+0x40;
val-=third;
// val&=0xff;
val=val>>2;
val=val+OFFSET;
final=((val-OFFSET)<<2)+third-0x40;
fprintf(stderr,"%d: %x -> %x %x ==> %x\n",
i,pv,val,third,final);
if (pv!=final) fprintf(stderr,"error0: no match!\n");
if (val<0) fprintf(stderr,"error0, negative! in=%x e=%x val=%x\n",
in[i+0],third,val);
if (val<0x20) fprintf(stderr,"error0, unprintable! in=%x pv=%x e=%x val=%x\n",
in[i+0],pv,third,val);
if (val>0x7e) fprintf(stderr,"error0, too big! in=%x pv=%x e=%x val=%x\n",
in[i+0],pv,third,val);
// printf("%c",val); //(in[i + 0] >> 2) + OFFSET);
//printf("%c",val); //(in[i + 0] >> 2) + OFFSET);
enc2[enc_ptr]=val;
enc_ptr++;
}
if (i + 1 < filesize) {
val=in[i+1];
pv=val;
val=val+0x40;
val-=(third>>2);
// val&=0xff;
val=val>>2;
val=val+OFFSET;
final=((val-OFFSET)<<2)+(third>>2)-0x40;
fprintf(stderr,"%d: %x -> %x %x ==> %x\n",
i+1,pv,val,third>>2,final);
if (pv!=final) fprintf(stderr,"error1: no match!\n");
if (val<0) fprintf(stderr,"error1, negative! %x %x\n",
in[i+0]&0xfc,third);
if (val<0x20) fprintf(stderr,"error1, unprintable! %x %x\n",
in[i+0]&0xfc,third);
if (val>0x7e) fprintf(stderr,"error1, too big! in=%x pv=%x e=%x val=%x\n",
in[i+0],pv,third,val);
// printf("%c",val); //(in[i + 1] >> 2) + OFFSET);
enc2[enc_ptr]=val;
enc_ptr++;
}
if (i + 2 < filesize) {
val=in[i+2];
pv=val;
val=val+0x40;
val-=(third>>4);
// val&=0xff;
val=val>>2;
val=val+OFFSET;
final=((val-OFFSET)<<2)+(third>>4)-0x40;
fprintf(stderr,"%d: %x -> %x %x ==> %x\n",
i+2,pv,val,third>>4,final);
if (pv!=final) fprintf(stderr,"error2: no match!\n");
if (val<0) fprintf(stderr,"error2, negative! %x %x\n",
in[i+0]&0xfc,third);
if (val<0x20) fprintf(stderr,"error2, unprintable! %x %x\n",
in[i+0]&0xfc,third);
if (val>0x7e) fprintf(stderr,"error2 too big! in=%x pv=%x e=%x val=%x\n",
in[i+0],pv,third,val);
// printf("%c",val);//(in[i + 2] >> 2) + OFFSET);
enc2[enc_ptr]=val;
enc_ptr++;
}
} while ((i += 3) < filesize);
enc[e]=0;
enc2[enc_ptr]=0;
printf("%s%s\n",enc2,enc);
return 0;
}

158
graphics/gr/bitmap/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