From 33af076cfc59a6232cd9230e4467149b68bb5128 Mon Sep 17 00:00:00 2001 From: uz Date: Mon, 26 Oct 2009 19:28:11 +0000 Subject: [PATCH] Lynx TGI driver update by Karri Kaksonen. Adds collision detection. git-svn-id: svn://svn.cc65.org/cc65/trunk@4393 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- doc/lynx.sgml | 13 +++++++++++-- include/lynx.h | 1 + libsrc/lynx/lynx-160-102-16.s | 26 ++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/doc/lynx.sgml b/doc/lynx.sgml index fa2a9dc51..856b909ec 100644 --- a/doc/lynx.sgml +++ b/doc/lynx.sgml @@ -46,7 +46,7 @@ that shows how to create a complete bootable Lynx cart. Memory layout

cc65 generated programs with the default setup run with the I/O area and the -kernal enabled, which gives a usable memory range of $400 - $C038. +kernal enabled, which gives a usable memory range of $400 - $C037. Special locations: @@ -62,12 +62,17 @@ Special locations: '?' for all keys down at the same time.

@@ -145,6 +150,10 @@ To update displays you can call tgi_updatedisplay() or tgi_ioctl(4, 1) it will wait for the next VBL interrupt and set the draw buffer to the view buffer. The draw buffer is also changed to (drawbuffer xor 1). +You can also enable or disable collision detection by a call to +tgi_setcollisiondetection(active) or tgi_ioctl(5, active). The collision +result is located before the sprite structure by default in this driver. + Extended memory drivers

No extended memory drivers are currently available for the Lynx. diff --git a/include/lynx.h b/include/lynx.h index c51d4cbf1..303260e33 100644 --- a/include/lynx.h +++ b/include/lynx.h @@ -109,6 +109,7 @@ void __fastcall__ lynx_eeprom_erase (unsigned char cell); #define tgi_setframerate(rate) tgi_ioctl(3, (unsigned)(rate)) #define tgi_busy() tgi_ioctl(4, 0) #define tgi_updatedisplay() tgi_ioctl(4, 1) +#define tgi_setcollisiondetection(active) tgi_ioctl(5, (unsigned)(active)) /* End of lynx.h */ #endif diff --git a/libsrc/lynx/lynx-160-102-16.s b/libsrc/lynx/lynx-160-102-16.s index 864ab554f..83e0c10af 100644 --- a/libsrc/lynx/lynx-160-102-16.s +++ b/libsrc/lynx/lynx-160-102-16.s @@ -199,6 +199,16 @@ INIT: ; Enable interrupts for VBL lda #$80 tsb VTIMCTLA +; Set up collision buffer to $A058 + lda #$58 + sta COLLBASL + lda #$A0 + sta COLLBASH +; Put collision index before sprite data + lda #$FE + sta COLLOFFL + lda #$FF + sta COLLOFFH ; Done, reset the error code lda #TGI_ERR_OK sta ERROR @@ -245,6 +255,8 @@ GETERROR: ; ; To update displays you can call tgi_ioctl(4, 1) it will wait for the ; next VBL interrupt and swap draw and view buffers. +; +; Activate or deactivate collision detection by calling tgi_ioctl(5, 0/1). CONTROL: pha ; Almost all control routines succeed @@ -252,6 +264,20 @@ CONTROL: sta ERROR pla + cmp #5 + bne ControlSwap + lda ptr1 + bne @L0 + lda __sprsys + ora #$20 + bra @L1 +@L0: lda __sprsys + and #$df +@L1: sta __sprsys + sta SPRSYS + rts + +ControlSwap: cmp #4 bne ControlFramerate -- 2.39.5