From 9c841c19c82481881f3cd520c7e58cb3acece9e1 Mon Sep 17 00:00:00 2001 From: uz Date: Sun, 1 Jan 2012 12:14:17 +0000 Subject: [PATCH] NES TGI Update by Stefan Haubenthal. git-svn-id: svn://svn.cc65.org/cc65/trunk@5352 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- doc/nes.sgml | 17 ++- libsrc/nes/Makefile | 1 + libsrc/nes/nes-64-56-2.s | 248 ++------------------------------------- libsrc/nes/tgi_colors.s | 8 ++ 4 files changed, 30 insertions(+), 244 deletions(-) create mode 100644 libsrc/nes/tgi_colors.s diff --git a/doc/nes.sgml b/doc/nes.sgml index d4e6a3fac..ea03ea34c 100644 --- a/doc/nes.sgml +++ b/doc/nes.sgml @@ -93,9 +93,19 @@ allow access to hardware located in the address space. Loadable drivers

+All drivers must be statically linked because no file I/O is available. +See the documentation for the +for information on how to do that. + Graphics drivers

-No graphics drivers are currently available for the NES. + + + + This driver features a resolution of 64×56 with 2 colors using the + CHR bank. + +

Extended memory drivers

@@ -104,10 +114,7 @@ No extended memory drivers are currently available for the NES. Joystick drivers

-A joystick driver for the standard buttons is available, but must be -statically linked, because no file I/O is available. See the documentation for -the for information on how to do -that. +A joystick driver for the standard four buttons joypad is available. Mouse drivers

diff --git a/libsrc/nes/Makefile b/libsrc/nes/Makefile index 0c2153c92..dfbc3d04e 100644 --- a/libsrc/nes/Makefile +++ b/libsrc/nes/Makefile @@ -65,6 +65,7 @@ OBJS = _scrsize.o \ revers.o \ setcursor.o \ sysuname.o \ + tgi_colors.o \ waitvblank.o \ wherex.o \ wherey.o diff --git a/libsrc/nes/nes-64-56-2.s b/libsrc/nes/nes-64-56-2.s index 8d824aeac..5b6ae404b 100644 --- a/libsrc/nes/nes-64-56-2.s +++ b/libsrc/nes/nes-64-56-2.s @@ -33,7 +33,7 @@ yres: .word 56 ; Max Y resolution .byte 2 ; System font X size .byte 2 ; System font Y size .word $100 ; Aspect ratio - .byte 0 ; TGI driver flags + .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). @@ -110,11 +110,11 @@ AY: .res 1 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 +; 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 +; 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 @@ -375,197 +375,6 @@ GETPIXEL: @L1: ldx #0 rts -; ------------------------------------------------------------------------ -; LINE: Draw a line from X1/Y1 to X2/Y2, where X1/Y1 = ptr1/ptr2 and -; X2/Y2 = ptr3/ptr4 using the current drawing color. -; -; Must set an error code: NO -; - -LINE: - ; nx = abs(x2 - x1) - lda X2 - sub X1 - sta NX - lda X2+1 - sbc X1+1 - tay - lda NX - jsr abs - sta NX - sty NX+1 - ; ny = abs(y2 - y1) - lda Y2 - sub Y1 - sta NY - lda Y2+1 - sbc Y1+1 - tay - lda NY - jsr abs - sta NY - sty NY+1 - ; if (x2>=x1) - ldx #X2 - lda X1 - ldy #0 - jsr icmp - bcc @L0243 - beq @L0243 - ; dx = 1; - lda #1 - bne @L0244 - ; else - ; dx = -1; -@L0243: lda #$ff -@L0244: sta DX - ; if (y2>=y1) - ldx #Y2 - lda Y1 - ldy #0 - jsr icmp - bcc @L024A - beq @L024A - ; dy = 1; - lda #1 - bne @L024B - ; else - ; dy = -1; -@L024A: lda #$ff -@L024B: sta DY - ; err = ay = 0; - lda #0 - sta ERR - sta ERR+1 - sta AY - - ; if (nx ny - lda NX - ldx NY - sta NY - stx NX - lda NX+1 - ldx NY+1 - sta NY+1 - stx NX+1 - ; ay = dx - lda DX - sta AY - ; dx = dy = 0; - lda #0 - sta DX - sta DY - ; ny = - ny; -@L0255: lda NY - ldy #0 - jsr neg - sta NY - sty NY+1 - ; for (count=nx;count>0;--count) { - lda NX - ldx #0 - sta COUNT - stx COUNT+1 -@L0166: lda COUNT ; count>0 - ora COUNT+1 - bne @L0167 - rts - ; setpixel(X1,Y1) -@L0167: jsr SETPIXEL - ; pb = err + ny - lda ERR - add NY - sta PB - lda ERR+1 - adc NY+1 - sta PB+1 - tax - ; ub = pb + nx - lda PB - add NX - sta UB - txa - adc NX+1 - sta UB+1 - ; x1 = x1 + dx - ldx #0 - lda DX - bpl @L027B - dex -@L027B: add X1 - sta X1 - txa - adc X1+1 - sta X1+1 - ; y1 = y1 + ay - ldx #0 - lda AY - bpl @L027E - dex -@L027E: add Y1 - sta Y1 - txa - adc Y1+1 - sta Y1+1 - ; if (abs(pb)