diff --git a/graphics/hgr/fake_bios/Makefile b/graphics/hgr/fake_bios/Makefile new file mode 100644 index 00000000..b8f42958 --- /dev/null +++ b/graphics/hgr/fake_bios/Makefile @@ -0,0 +1,36 @@ +include ../../../Makefile.inc + +DOS33 = ../../../utils/dos33fs-utils/dos33 +DOS33_RAW = ../../../utils/dos33fs-utils/dos33_raw +TOKENIZE = ../../../utils/asoft_basic-utils/tokenize_asoft +LINKER_SCRIPTS = ../../../linker_scripts +EMPTY_DISK = ../../../empty_disk + +all: fake_bios.dsk + +fake_bios.dsk: HELLO FAKE_BIOS + cp $(EMPTY_DISK)/empty.dsk fake_bios.dsk + $(DOS33) -y fake_bios.dsk SAVE A HELLO + $(DOS33) -y fake_bios.dsk BSAVE -a 0x6000 FAKE_BIOS + +### + +HELLO: hello.bas + $(TOKENIZE) < hello.bas > HELLO + +### + +FAKE_BIOS: fake_bios.o + ld65 -o FAKE_BIOS fake_bios.o -C $(LINKER_SCRIPTS)/apple2_6000.inc + +fake_bios.o: fake_bios.s \ + hgr_clear_screen.s \ + font_console_1x8.s fonts/a2_cga_thin.inc \ + zx02_optim.s graphics/a2_energy.hgr.zx02 + ca65 -o fake_bios.o fake_bios.s -l fake_bios.lst + +### + +clean: + rm -f *~ *.o *.lst HELLO FAKE_BIOS + diff --git a/graphics/hgr/hgr_font_4am/bios_test.s b/graphics/hgr/fake_bios/fake_bios.s similarity index 100% rename from graphics/hgr/hgr_font_4am/bios_test.s rename to graphics/hgr/fake_bios/fake_bios.s diff --git a/graphics/hgr/fake_bios/font_console_1x8.s b/graphics/hgr/fake_bios/font_console_1x8.s new file mode 100644 index 00000000..1ed4811c --- /dev/null +++ b/graphics/hgr/fake_bios/font_console_1x8.s @@ -0,0 +1,251 @@ +;license:MIT +;(c) 2023 by 4am +; +; drawing routines for Million Perfect Tiles Condensed +; +; Public functions: +; - DrawCondensedString +; + +; VMW: commented, reformatted, minor changes, ca65 assembly +; hacked up some more + +FONT_OFFSET = $13 + + +;------------------------------------------------------------------------------ +; DrawCondensedString +; +; in: A/Y points to zero terminated string, with x-pos and y-pos at start +; out: clobbers all registers & flags +;------------------------------------------------------------------------------ +DrawCondensedString: + + ; store the string location + + sta OUTL + sty OUTH + +DrawCondensedStringAgain: + + lda OUTL + sta dcb_loop_smc+1 + lda OUTH + sta dcb_loop_smc+2 + + + ldy CV + + ; row0 + + lda hposn_low, Y ; get low memory offset + clc + adc CH ; add in x-coord + sta dcb_row0+4 + lda hposn_high, Y ; get high memory offset + sta dcb_row0+5 ; save it out + iny ; go to next row + + ; row1 + + lda hposn_low, Y + adc CH + sta dcb_row1+4 + lda hposn_high, Y + sta dcb_row1+5 + iny + + ; row2 + + lda hposn_low, Y + adc CH + sta dcb_row2+4 + lda hposn_high, Y + sta dcb_row2+5 + iny + + ; row3 + + lda hposn_low, Y + adc CH + sta dcb_row3+4 + lda hposn_high, Y + sta dcb_row3+5 + iny + + ; row4 + + lda hposn_low, Y + adc CH + sta dcb_row4+4 + lda hposn_high, Y + sta dcb_row4+5 + iny + + ; row5 + + lda hposn_low, Y + adc CH + sta dcb_row5+4 + lda hposn_high, Y + sta dcb_row5+5 + iny + + ; row6 + + lda hposn_low, Y + adc CH + sta dcb_row6+4 + lda hposn_high, Y + sta dcb_row6+5 + iny + + ; row7 + + lda hposn_low, Y + adc CH + sta dcb_row7+4 + lda hposn_high, Y + sta dcb_row7+5 + + ldx #0 +dcb_loop: +dcb_loop_smc: + ldy $FDFD, X ; load next char into Y + beq dcb_done + + cpy #13 + bne not_linefeed + + lda #0 + sta CH + clc + lda CV + adc #8 + sta CV + inx + + lda CV + cmp #192 + bcc dcb_loop + + lda #184 + sta CV + + stx XSAVE + jsr scroll_screen + ldx XSAVE + + jmp dcb_loop + + +not_linefeed: + ; unrolled loop to write out each line + +dcb_row0: + lda CondensedRow0-FONT_OFFSET, Y ; get 1-byte font row + sta $FDFD, X ; write out to graphics mem +dcb_row1: + lda CondensedRow1-FONT_OFFSET, Y + sta $FDFD, X +dcb_row2: + lda CondensedRow2-FONT_OFFSET, Y + sta $FDFD, X +dcb_row3: + lda CondensedRow3-FONT_OFFSET, Y + sta $FDFD, X +dcb_row4: + lda CondensedRow4-FONT_OFFSET, Y + sta $FDFD, X +dcb_row5: + lda CondensedRow5-FONT_OFFSET, Y + sta $FDFD, X +dcb_row6: + lda CondensedRow6-FONT_OFFSET, Y + sta $FDFD, X +dcb_row7: + lda CondensedRow7-FONT_OFFSET, Y + sta $FDFD, X + + inc CH + inx ; move to next + + bne dcb_loop ; bra (well, as long as string + ; is less than 255 chars) + +dcb_done: + + ; point to location after + sec ; always add 1 + txa + adc OUTL + sta OUTL + lda #0 + adc OUTH + sta OUTH + + rts + + + ;================================ + ;================================ + ; scroll_screen + ;================================ + ;================================ + ; scrolls hgr page1 up by 8, filling with empty space at bottom + ; trashes A,X,Y + +scroll_screen: + ldx #8 + stx SCROLL_IN + ldx #0 + stx SCROLL_OUT + +scroll_yloop: + ldx SCROLL_IN + lda hposn_low,X + sta xloop_smc1+1 + lda hposn_high,X + sta xloop_smc1+2 + + ldx SCROLL_OUT + lda hposn_low,X + sta xloop_smc2+1 + lda hposn_high,X + sta xloop_smc2+2 + + ldy #39 +scroll_xloop: +xloop_smc1: + lda $2000,Y +xloop_smc2: + sta $2000,Y + dey + bpl scroll_xloop + + inc SCROLL_IN + inc SCROLL_OUT + + lda SCROLL_IN + cmp #192 + bne scroll_yloop + + ; blank bottom line + + + lda #$00 + ldy #39 +scroll_hline_xloop: + sta $23D0,Y + sta $27D0,Y + sta $2BD0,Y + sta $2FD0,Y + sta $33D0,Y + sta $37D0,Y + sta $3BD0,Y + sta $3FD0,Y + dey + bpl scroll_hline_xloop + + rts + diff --git a/graphics/hgr/fake_bios/fonts/Makefile b/graphics/hgr/fake_bios/fonts/Makefile new file mode 100644 index 00000000..187b53f6 --- /dev/null +++ b/graphics/hgr/fake_bios/fonts/Makefile @@ -0,0 +1,10 @@ +PNG2FONT = ../../../../utils/hgr-utils/png2font + + +all: a2_cga_thin.inc + +a2_cga_thin.inc: a2_cga_thin.png + $(PNG2FONT) -i -o 0x13 a2_cga_thin.png > a2_cga_thin.inc + +clean: + rm -f *~ *.inc diff --git a/graphics/hgr/fake_bios/fonts/a2_cga_thin.png b/graphics/hgr/fake_bios/fonts/a2_cga_thin.png new file mode 100644 index 00000000..43576603 Binary files /dev/null and b/graphics/hgr/fake_bios/fonts/a2_cga_thin.png differ diff --git a/graphics/hgr/hgr_font_4am/graphics/Makefile b/graphics/hgr/fake_bios/graphics/Makefile similarity index 100% rename from graphics/hgr/hgr_font_4am/graphics/Makefile rename to graphics/hgr/fake_bios/graphics/Makefile diff --git a/graphics/hgr/hgr_font_4am/graphics/a2_energy.png b/graphics/hgr/fake_bios/graphics/a2_energy.png similarity index 100% rename from graphics/hgr/hgr_font_4am/graphics/a2_energy.png rename to graphics/hgr/fake_bios/graphics/a2_energy.png diff --git a/graphics/hgr/fake_bios/hardware.inc b/graphics/hgr/fake_bios/hardware.inc new file mode 100644 index 00000000..63eb36df --- /dev/null +++ b/graphics/hgr/fake_bios/hardware.inc @@ -0,0 +1,102 @@ +; 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 +PAGE1 = $C054 +PAGE2 = $C055 +LORES = $C056 ; Enable LORES graphics +HIRES = $C057 ; Enable HIRES graphics +AN3 = $C05E ; Annunciator 3 + +PADDLE_BUTTON0 = $C061 +PADDL0 = $C064 +PTRIG = $C070 + +; APPLESOFT BASIC ROUTINES + +NORMAL = $F273 +HGR2 = $F3D8 +HGR = $F3E2 +BKGND0 = $F3F4 ; clear current page to A +HPOSN = $F411 ; (Y,X),(A) (values stores in HGRX,XH,Y) +HPLOT0 = $F457 ; plot at (Y,X), (A) +COLOR_SHIFT = $F47E +HLINRL = $F530 ; (X,A),(Y) +HGLIN = $F53A ; line to (X,A),(Y) +COLORTBL = $F6F6 + + +; 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 +ROM_TEXT2COPY = $F962 ; iigs +TEXT = $FB36 +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 + diff --git a/graphics/hgr/fake_bios/hello.bas b/graphics/hgr/fake_bios/hello.bas new file mode 100644 index 00000000..e7fa4a3f --- /dev/null +++ b/graphics/hgr/fake_bios/hello.bas @@ -0,0 +1,5 @@ +5 HOME +10 PRINT CHR$(4)"BRUN FAKE_BIOS" + + + diff --git a/graphics/hgr/hgr_font_4am/hgr_clear_screen.s b/graphics/hgr/fake_bios/hgr_clear_screen.s similarity index 100% rename from graphics/hgr/hgr_font_4am/hgr_clear_screen.s rename to graphics/hgr/fake_bios/hgr_clear_screen.s diff --git a/graphics/hgr/fake_bios/hgr_table.s b/graphics/hgr/fake_bios/hgr_table.s new file mode 100644 index 00000000..3462059b --- /dev/null +++ b/graphics/hgr/fake_bios/hgr_table.s @@ -0,0 +1,37 @@ +; hposn_low, hposn_high will each be filled with $C0 bytes +; based on routine by John Brooks +; posted on comp.sys.apple2 on 2018-07-11 +; https://groups.google.com/d/msg/comp.sys.apple2/v2HOfHOmeNQ/zD76fJg_BAAJ +; clobbers A,X +; preserves Y + +; vmw note: version I was using based on applesoft HPOSN was ~64 bytes +; this one is 37 bytes + +build_tables: + ldx #0 +btmi: + txa + and #$F8 + bpl btpl1 + ora #5 +btpl1: + asl + bpl btpl2 + ora #5 +btpl2: + asl + asl + sta hposn_low, X + txa + and #7 + rol + asl hposn_low, X + rol + ora #$20 + sta hposn_high, X + inx + cpx #$C0 + bne btmi + + rts diff --git a/graphics/hgr/fake_bios/scroll.s b/graphics/hgr/fake_bios/scroll.s new file mode 100644 index 00000000..4ef6fe12 --- /dev/null +++ b/graphics/hgr/fake_bios/scroll.s @@ -0,0 +1,58 @@ + ;================================ + ;================================ + ;================================ + ;================================ +scroll_screen: + ldx #8 + stx INL + ldx #0 + stx OUTL + +scroll_yloop: + ldx INL + lda hposn_low,X + sta xloop_smc1+1 + lda hposn_high,X + sta xloop_smc1+2 + + ldx OUTL + lda hposn_low,X + sta xloop_smc2+1 + lda hposn_high,X + sta xloop_smc2+2 + + ldy #39 +scroll_xloop: +xloop_smc1: + lda $2000,Y +xloop_smc2: + sta $2000,Y + dey + bpl scroll_xloop + + inc INL + inc OUTL + + lda INL + cmp #192 + bne scroll_yloop + + ; blank bottom line + + + lda #$00 + ldy #39 +scroll_hline_xloop: + sta $23D0,Y + sta $27D0,Y + sta $2BD0,Y + sta $2FD0,Y + sta $33D0,Y + sta $37D0,Y + sta $3BD0,Y + sta $3FD0,Y + dey + bpl scroll_hline_xloop + + rts + diff --git a/graphics/hgr/fake_bios/zp.inc b/graphics/hgr/fake_bios/zp.inc new file mode 100644 index 00000000..35e9c221 --- /dev/null +++ b/graphics/hgr/fake_bios/zp.inc @@ -0,0 +1,46 @@ +; zx02 code +offset = $10 +offseth = $11 +ZX0_src = $12 +ZX0_dst = $14 +ZX0_srch= $15 +bitr = $16 +pntr = $17 +pntrh = $18 + + +;TEMP0 = $10 +;TEMP1 = $11 +;TEMP2 = $12 +;TEMP3 = $13 +;TEMP4 = $14 +;TEMP5 = $15 + + +HGR_BITS = $1C + +CH = $24 +CV = $25 +GBASL = $26 +GBASH = $27 +CURSOR_X = $62 +CURSOR_Y = $63 +HGR_COLOR = $E4 +P0 = $F1 +P1 = $F2 +P2 = $F3 +P3 = $F4 +P4 = $F5 +P5 = $F6 + +XSAVE = $F6 +SCROLL_IN=$F7 +SCROLL_OUT=$F8 + +STRING_COUNT = $F9 +MEMCOUNT= $FA +LEAD0 = $FB +INL = $FC +INH = $FD +OUTL = $FE +OUTH = $FF diff --git a/graphics/hgr/hgr_font_4am/zx02_optim.s b/graphics/hgr/fake_bios/zx02_optim.s similarity index 100% rename from graphics/hgr/hgr_font_4am/zx02_optim.s rename to graphics/hgr/fake_bios/zx02_optim.s diff --git a/graphics/hgr/hgr_font_4am/Makefile b/graphics/hgr/hgr_font_4am/Makefile index c912aecd..3e69aee9 100644 --- a/graphics/hgr/hgr_font_4am/Makefile +++ b/graphics/hgr/hgr_font_4am/Makefile @@ -8,10 +8,9 @@ EMPTY_DISK = ../../../empty_disk all: hgr_font4.dsk -hgr_font4.dsk: HELLO BIOS_TEST FONT_4AM_TEST FONT_VMW_10_TEST FONT_VMW_8_TEST +hgr_font4.dsk: HELLO FONT_4AM_TEST FONT_VMW_10_TEST FONT_VMW_8_TEST cp $(EMPTY_DISK)/empty.dsk hgr_font4.dsk $(DOS33) -y hgr_font4.dsk SAVE A HELLO - $(DOS33) -y hgr_font4.dsk BSAVE -a 0x6000 BIOS_TEST $(DOS33) -y hgr_font4.dsk BSAVE -a 0x6000 FONT_4AM_TEST $(DOS33) -y hgr_font4.dsk BSAVE -a 0x6000 FONT_VMW_10_TEST $(DOS33) -y hgr_font4.dsk BSAVE -a 0x6000 FONT_VMW_8_TEST @@ -23,17 +22,6 @@ HELLO: hello.bas ### -BIOS_TEST: bios_test.o - ld65 -o BIOS_TEST bios_test.o -C $(LINKER_SCRIPTS)/apple2_6000.inc - -bios_test.o: bios_test.s \ - hgr_clear_screen.s \ - font_console_1x8.s fonts/a2_cga_thin.inc \ - zx02_optim.s graphics/a2_energy.hgr.zx02 - ca65 -o bios_test.o bios_test.s -l bios_test.lst - -### - FONT_4AM_TEST: font_4am_test.o ld65 -o FONT_4AM_TEST font_4am_test.o -C $(LINKER_SCRIPTS)/apple2_6000.inc