X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libsrc%2Fnes%2Ftgi%2Fnes-64-56-2.s;h=cce83e2315bd3ccfff1878b1ee5b677f749dd2ec;hb=1354e1265fd8353af51ab3275a833681c293c345;hp=f41e63d886fe963a713159e696b0f2f81dcb0e56;hpb=983c6285e1578902e8294c870582f3bca7593dc8;p=cc65 diff --git a/libsrc/nes/tgi/nes-64-56-2.s b/libsrc/nes/tgi/nes-64-56-2.s index f41e63d88..cce83e231 100644 --- a/libsrc/nes/tgi/nes-64-56-2.s +++ b/libsrc/nes/tgi/nes-64-56-2.s @@ -5,59 +5,59 @@ ; Based on Maciej Witkowiak's line routine. ; - .include "zeropage.inc" + .include "zeropage.inc" - .include "tgi-kernel.inc" - .include "tgi-error.inc" - .include "nes.inc" - .include "get_tv.inc" - .import _clrscr, setcursor, putchar - .import paldata + .include "tgi-kernel.inc" + .include "tgi-error.inc" + .include "nes.inc" + .include "get_tv.inc" + .import _clrscr, setcursor, putchar + .import paldata - .macpack generic + .macpack generic ; ------------------------------------------------------------------------ ; Header. Includes jump table and constants. -.segment "JUMPTABLE" +.segment "JUMPTABLE" ; First part of the header is a structure that has a magic and defines the ; capabilities of the driver - .byte $74, $67, $69 ; "tgi" - .byte TGI_API_VERSION ; TGI API version number -xres: .word charsperline*2 ; Max X resolution -yres: .word 56 ; Max Y resolution - .byte 2 ; Number of drawing colors - .byte 1 ; Number of screens available - .byte 2 ; System font X size - .byte 2 ; System font Y size - .word $100 ; Aspect ratio - .byte 0 ; TGI driver flags + .byte $74, $67, $69 ; "tgi" + .byte TGI_API_VERSION ; TGI API version number +xres: .word charsperline*2 ; Max X resolution +yres: .word 56 ; Max Y resolution + .byte 2 ; Number of drawing colors + .byte 1 ; Number of screens available + .byte 2 ; System font X size + .byte 2 ; System font Y size + .word $100 ; Aspect ratio + .byte 0 ; TGI driver flags ; Next comes the jump table. Currently all entries must be valid and may point ; to an RTS for test versions (function not implemented). - .addr INSTALL - .addr UNINSTALL - .addr INIT - .addr DONE - .addr GETERROR - .addr CONTROL - .addr CLEAR - .addr SETVIEWPAGE - .addr SETDRAWPAGE - .addr SETCOLOR - .addr SETPALETTE - .addr GETPALETTE - .addr GETDEFPALETTE - .addr SETPIXEL - .addr GETPIXEL - .addr LINE - .addr BAR - .addr TEXTSTYLE - .addr OUTTEXT - .addr 0 ; IRQ entry is unused + .addr INSTALL + .addr UNINSTALL + .addr INIT + .addr DONE + .addr GETERROR + .addr CONTROL + .addr CLEAR + .addr SETVIEWPAGE + .addr SETDRAWPAGE + .addr SETCOLOR + .addr SETPALETTE + .addr GETPALETTE + .addr GETDEFPALETTE + .addr SETPIXEL + .addr GETPIXEL + .addr LINE + .addr BAR + .addr TEXTSTYLE + .addr OUTTEXT + .addr 0 ; IRQ entry is unused ; ------------------------------------------------------------------------ ; Data. @@ -65,57 +65,57 @@ yres: .word 56 ; Max Y resolution ; Variables mapped to the zero page segment variables. Some of these are ; used for passing parameters to the driver. -X1 = ptr1 -Y1 = ptr2 -X2 = ptr3 -Y2 = ptr4 -RADIUS = tmp1 +X1 = ptr1 +Y1 = ptr2 +X2 = ptr3 +Y2 = ptr4 +RADIUS = tmp1 -ADDR = tmp1 -TEMP = tmp3 -TEMP2 = tmp4 -TEMP3 = sreg -TEMP4 = sreg+1 +ADDR = tmp1 +TEMP = tmp3 +TEMP2 = tmp4 +TEMP3 = sreg +TEMP4 = sreg+1 ; Line routine stuff (must be on zpage) -PB = ptr3 ; (2) LINE -UB = ptr4 ; (2) LINE -ERR = regsave ; (2) LINE -NX = regsave+2 ; (2) LINE +PB = ptr3 ; (2) LINE +UB = ptr4 ; (2) LINE +ERR = regsave ; (2) LINE +NX = regsave+2 ; (2) LINE ; Absolute variables used in the code .bss -MEM: .res charsperline*2*56/4 +MEM: .res charsperline*2*56/4 MEMEND: -ERROR: .res 1 ; Error code -COLOR: .res 1 ; Current color -PALETTE: .res 2 ; The current palette +ERROR: .res 1 ; Error code +COLOR: .res 1 ; Current color +PALETTE: .res 2 ; The current palette ; Line routine stuff OGora: -COUNT: .res 2 +COUNT: .res 2 OUkos: -NY: .res 2 +NY: .res 2 Y3: -DX: .res 1 -DY: .res 1 -AY: .res 1 +DX: .res 1 +DY: .res 1 +AY: .res 1 ; Constants and tables .rodata -DEFPALETTE: .byte $0, $1 -OFFSET: .byte 8, 4, 2, 1 -; 00 00 00 00 01 01 01 01 -; 00 01 10 11 00 01 10 11 -CODE: .byte 32, 29, 26, 25, 28, 24+128, 31+128, 30+128 -; 10 10 10 10 11 11 11 11 -; 00 01 10 11 00 01 10 11 - .byte 30, 31, 24, 28+128, 25+128, 26+128, 29+128, 32+128 +DEFPALETTE: .byte $0, $1 +OFFSET: .byte 8, 4, 2, 1 +; 00 00 00 00 01 01 01 01 +; 00 01 10 11 00 01 10 11 +CODE: .byte 32, 29, 26, 25, 28, 24+128, 31+128, 30+128 +; 10 10 10 10 11 11 11 11 +; 00 01 10 11 00 01 10 11 + .byte 30, 31, 24, 28+128, 25+128, 26+128, 29+128, 32+128 .code @@ -128,13 +128,13 @@ CODE: .byte 32, 29, 26, 25, 28, 24+128, 31+128, 30+128 ; INSTALL: - jsr _get_tv - cmp #TV::NTSC - beq ntsc + jsr _get_tv + cmp #TV::NTSC + beq ntsc ; TODO ROM! - inc yres - inc yres -ntsc:; rts + inc yres + inc yres +ntsc:; rts ; ------------------------------------------------------------------------ ; UNINSTALL routine. Is called before the driver is removed from memory. May @@ -144,7 +144,7 @@ ntsc:; rts ; UNINSTALL: - rts + rts ; ------------------------------------------------------------------------ ; INIT: Changes an already installed device from text mode to graphics @@ -164,9 +164,9 @@ INIT: ; Done, reset the error code - lda #TGI_ERR_OK - sta ERROR -; rts + lda #TGI_ERR_OK + sta ERROR +; rts ; ------------------------------------------------------------------------ ; DONE: Will be called to switch the graphics device back into text mode. @@ -177,16 +177,16 @@ INIT: ; DONE: - rts + rts ; ------------------------------------------------------------------------ ; GETERROR: Return the error code in A and clear it. GETERROR: - lda ERROR - ldx #TGI_ERR_OK - stx ERROR - rts + lda ERROR + ldx #TGI_ERR_OK + stx ERROR + rts ; ------------------------------------------------------------------------ ; CONTROL: Platform/driver specific entry point. @@ -195,9 +195,9 @@ GETERROR: ; CONTROL: - lda #TGI_ERR_INV_FUNC - sta ERROR - rts + lda #TGI_ERR_INV_FUNC + sta ERROR + rts ; ------------------------------------------------------------------------ ; CLEAR: Clears the screen. @@ -206,20 +206,20 @@ CONTROL: ; CLEAR: - ldx #MEM - stx TEMP+1 - lda #0 - tay -@L1: sta (TEMP),y - iny - bne @L1 - inc TEMP+1 - inx - cpx #>MEMEND - bne @L1 - jmp _clrscr + ldx #MEM + stx TEMP+1 + lda #0 + tay +@L1: sta (TEMP),y + iny + bne @L1 + inc TEMP+1 + inx + cpx #>MEMEND + bne @L1 + jmp _clrscr ; ------------------------------------------------------------------------ ; SETCOLOR: Set the drawing color (in A). The new color is already checked @@ -229,8 +229,8 @@ CLEAR: ; SETCOLOR: - sta COLOR -; rts + sta COLOR +; rts ; ------------------------------------------------------------------------ ; SETVIEWPAGE: Set the visible page. Called with the new page in A (0..n). @@ -249,7 +249,7 @@ SETVIEWPAGE: ; SETDRAWPAGE: - rts + rts ; ------------------------------------------------------------------------ ; SETPALETTE: Set the palette (not available with all drivers/hardware). @@ -261,31 +261,31 @@ SETDRAWPAGE: SETPALETTE: ; Wait for v-blank -@wait: lda PPU_STATUS - bpl @wait - - lda #$3F - sta PPU_VRAM_ADDR2 - lda #$00 - sta PPU_VRAM_ADDR2 - - ldy #0 - lda (ptr1),y - sta PALETTE - tax - lda paldata,x -; sta PPU_VRAM_IO - - iny - lda (ptr1),y - sta PALETTE+1 - tax - lda paldata,x - sta PPU_VRAM_IO - - lda #TGI_ERR_OK - sta ERROR - rts +@wait: lda PPU_STATUS + bpl @wait + + lda #$3F + sta PPU_VRAM_ADDR2 + lda #$00 + sta PPU_VRAM_ADDR2 + + ldy #0 + lda (ptr1),y + sta PALETTE + tax + lda paldata,x +; sta PPU_VRAM_IO + + iny + lda (ptr1),y + sta PALETTE+1 + tax + lda paldata,x + sta PPU_VRAM_IO + + lda #TGI_ERR_OK + sta ERROR + rts ; ------------------------------------------------------------------------ ; GETPALETTE: Return the current palette in A/X. Even drivers that cannot @@ -296,9 +296,9 @@ SETPALETTE: ; GETPALETTE: - lda #PALETTE - rts + lda #PALETTE + rts ; ------------------------------------------------------------------------ ; GETDEFPALETTE: Return the default palette for the driver in A/X. All @@ -310,9 +310,9 @@ GETPALETTE: ; GETDEFPALETTE: - lda #DEFPALETTE - rts + lda #DEFPALETTE + rts ; ------------------------------------------------------------------------ ; SETPIXEL: Draw one pixel at X1/Y1 = ptr1/ptr2 with the current drawing @@ -323,41 +323,41 @@ GETDEFPALETTE: ; SETPIXEL: - ldx Y1 ; y+2= 0) && (X1 < XRES) -; (X2 >= 0) && (X2 < XRES) -; (Y1 >= 0) && (Y1 < YRES) -; (Y2 >= 0) && (Y2 < YRES) +; X1 <= X2 +; Y1 <= Y2 +; (X1 >= 0) && (X1 < XRES) +; (X2 >= 0) && (X2 < XRES) +; (Y1 >= 0) && (Y1 < YRES) +; (Y2 >= 0) && (Y2 < YRES) ; ; Must set an error code: NO ; BAR: - inc Y2 -@L1: lda X1 - pha -@L2: jsr SETPIXEL - inc X1 - lda X2 - cmp X1 - bne @L2 - pla - sta X1 - inc Y1 - lda Y2 - cmp Y1 - bne @L1 - rts + inc Y2 +@L1: lda X1 + pha +@L2: jsr SETPIXEL + inc X1 + lda X2 + cmp X1 + bne @L2 + pla + sta X1 + inc Y1 + lda Y2 + cmp Y1 + bne @L1 + rts ; ------------------------------------------------------------------------ ; TEXTSTYLE: Set the style used when calling OUTTEXT. Text scaling in X and Y @@ -416,7 +416,7 @@ BAR: ; TEXTSTYLE: - rts + rts ; ------------------------------------------------------------------------ ; OUTTEXT: Output text at X/Y = ptr1/ptr2 using the current color and the @@ -427,68 +427,68 @@ TEXTSTYLE: ; OUTTEXT: - lda ptr1 - lsr - tay - lda ptr2 - lsr - tax - clc - jsr setcursor - ldy #0 -@L1: lda (ptr3),y - jsr putchar - iny - cmp #$0 - bne @L1 - rts + lda ptr1 + lsr + tay + lda ptr2 + lsr + tax + clc + jsr setcursor + ldy #0 +@L1: lda (ptr3),y + jsr putchar + iny + cmp #$0 + bne @L1 + rts ; ------------------------------------------------------------------------ ; Calculate all variables to plot the pixel at X1/Y1. If the point is out ; of range, a carry is returned and INRANGE is set to a value !0 zero. If ; the coordinates are valid, INRANGE is zero and the carry clear. -CALC: lda xres - sta TEMP - lda #0 - sta TEMP+1 - ldy Y1 -@L1: lda TEMP - add xres - lsr - sta TEMP - lda TEMP+1 - adc #0 - lsr - sta TEMP+1 - dey - bne @L1 - lda TEMP - add X1 - lsr - sta TEMP - lda TEMP+1 - adc #0 - lsr - sta TEMP+1 - lda TEMP - add #MEM - sta TEMP+1 - - lda X1 - and #%00000001 - sta TEMP3 - lda Y1 - asl - and #%00000010 - ora TEMP3 - tax - lda OFFSET,x - rts +CALC: lda xres + sta TEMP + lda #0 + sta TEMP+1 + ldy Y1 +@L1: lda TEMP + add xres + lsr + sta TEMP + lda TEMP+1 + adc #0 + lsr + sta TEMP+1 + dey + bne @L1 + lda TEMP + add X1 + lsr + sta TEMP + lda TEMP+1 + adc #0 + lsr + sta TEMP+1 + lda TEMP + add #MEM + sta TEMP+1 + + lda X1 + and #%00000001 + sta TEMP3 + lda Y1 + asl + and #%00000010 + ora TEMP3 + tax + lda OFFSET,x + rts ; ------------------------------------------------------------------------ -.include "../../tgi/tgidrv_line.inc" +.include "../../tgi/tgidrv_line.inc"