From c9de0e68418270b30fd5e77935c74c1fd4d14799 Mon Sep 17 00:00:00 2001 From: uz Date: Sun, 13 Sep 2009 13:37:44 +0000 Subject: [PATCH] Lynx changes by Karri Kaksonen. git-svn-id: svn://svn.cc65.org/cc65/trunk@4164 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- doc/lynx.sgml | 27 +++++++++++++++++++++------ include/lynx.h | 27 +++++++++++++++++++++++++++ libsrc/lynx/crt0.s | 2 ++ libsrc/lynx/lynx-160-102-16.s | 15 ++++++++------- 4 files changed, 58 insertions(+), 13 deletions(-) diff --git a/doc/lynx.sgml b/doc/lynx.sgml index 424c53caf..95745278c 100644 --- a/doc/lynx.sgml +++ b/doc/lynx.sgml @@ -125,14 +125,29 @@ single-buffer device set draw page and view page to the same value 0 or 1; The TGI driver has a few Lynx-specific extensions. -Calling tgi_ioctl(0, spr) will display a standard Lynx sprite on screen. +Calling tgi_sprite(spr) or tgi_ioctl(0, spr) will display a standard Lynx +sprite on screen. -Calling tgi_ioctl(1, 0) will do a flip screen. If you decide to flip the -screen then it may be a good idea to call the install-routine for the -joystick to get that flipped too. +Calling tgi_flip() or tgi_ioctl(1, 0) will do a flip screen. -Calling tgi_ioctl(2, bgindex) will set the text background color to the index -defined by bgindex. If bgindex is 0 then the background color is transparent. +Calling tgi_setbgcolor(bgcolor) or tgi_ioctl(2, bgindex) will set the text +background color to the index defined by bgindex. If bgindex is 0 then the +background color is transparent. + +To set the framerate of the display hardware call tgi_setframerate(rate) or +tgi_ioctl(3, rate). The supported framerates are 50, 60 and 75 frames per +second. Actually there is no real reason to use anything else than 75 frames +per second. + +To check if the drawing engine is busy with the previous swap you can +call tgi_busy or tgi_ioctl(4, 0). It returns 0 if idle and 1 if busy + +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). + +Set an address for a subroutine you want to call at every VBL by calling +tgi_setvblhook(addr) or tgi_ioctl(5, addr). Extended memory drivers

diff --git a/include/lynx.h b/include/lynx.h index 365bcebb4..391a834ec 100644 --- a/include/lynx.h +++ b/include/lynx.h @@ -100,6 +100,33 @@ void __fastcall__ lynx_eeprom_erase (unsigned char cell); +/*****************************************************************************/ +/* TGI extras */ +/*****************************************************************************/ + + + +#define tgi_sprite(spr) tgi_ioctl(0, (unsigned)(spr)) +#define tgi_flip() tgi_ioctl(1, 0) +#define tgi_setbgcolor(bgcol) tgi_ioctl(2, (unsigned)(bgcol)) +#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_setvblhook(addr) tgi_ioctl(5, (unsigned)(addr)) + + +/*****************************************************************************/ +/* TGI extras */ +/*****************************************************************************/ + +#define tgi_sprite(spr) tgi_ioctl(0, (unsigned)(spr)) +#define tgi_flip() tgi_ioctl(1, 0) +#define tgi_setbgcolor(bgcol) tgi_ioctl(2, (unsigned)(bgcol)) +#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_setvblhook(addr) tgi_ioctl(5, (unsigned)(addr)) + /* End of lynx.h */ #endif diff --git a/libsrc/lynx/crt0.s b/libsrc/lynx/crt0.s index 4f210df7b..245dd1207 100644 --- a/libsrc/lynx/crt0.s +++ b/libsrc/lynx/crt0.s @@ -168,6 +168,8 @@ IRQStub: pha cld jsr callirq + lda INTSET + sta INTRST pla plx ply diff --git a/libsrc/lynx/lynx-160-102-16.s b/libsrc/lynx/lynx-160-102-16.s index 7825e2d8e..f37723df9 100644 --- a/libsrc/lynx/lynx-160-102-16.s +++ b/libsrc/lynx/lynx-160-102-16.s @@ -240,10 +240,11 @@ GETERROR: ; ; To set the frame rate for the display hardware call tgi_ioctl(3, rate) ; -; To make a request for swapping the display buffers call tgi_ioctl(4, dataptr) -; If the value of the char pointed to by the dataptr is 0 then fill in the -; value of the char with the current state of the swap buffer 0 = idle, 1 = busy -; If the value is not 0 then activate the swap function at next VBL interrupt +; To check if the drawing engine is busy with the previous swap you can +; call tgi_ioctl(4, 0). It returns 0 if idle and 1 if busy +; +; To update displays you can call tgi_ioctl(4, 1) it will wait for the +; next VBL interrupt and swap draw and view buffers. ; ; Set an address for a subroutine you want to call at every VBL ; tgi_ioctl(5, hook) @@ -468,9 +469,9 @@ IRQ: bne IRQVBL clc ; Not a VBL interrupt - exit rts -IRQVBL: sta INTRST ; Clear interrupt +IRQVBL: lda SWAPREQUEST - bne @L0 + beq @L0 lda DRAWPAGE jsr SETVIEWPAGE lda DRAWPAGE @@ -480,7 +481,7 @@ IRQVBL: sta INTRST ; Clear interrupt stz SWAPREQUEST @L0: jsr VBLHOOK - sec + clc rts ; ------------------------------------------------------------------------ -- 2.39.5