From eb6003aaf77d91c39e81b7bd54bd206c15a0f19f Mon Sep 17 00:00:00 2001 From: Alex Thissen Date: Fri, 9 Aug 2024 13:11:02 +0200 Subject: [PATCH 01/11] Mikey enumeration values for cc65 include files and new bit definitions for ca65 --- asminc/lynx.inc | 347 ++++++++++++++++++++++++++++++----------------- include/_mikey.h | 255 +++++++++++++++++++++++++++------- 2 files changed, 430 insertions(+), 172 deletions(-) diff --git a/asminc/lynx.inc b/asminc/lynx.inc index 0d34e1c7c..d6a8cd70a 100644 --- a/asminc/lynx.inc +++ b/asminc/lynx.inc @@ -83,7 +83,7 @@ MATHJ = $FC6F SPRCTL0 = $FC80 ; Sprite bits-per-pixel definitions -BPP_MASK = %11000000 ; Mask for settings bits per pixel +BPP_MASK = %11000000 ; Mask for settings bits per pixel BPP_1 = %00000000 BPP_2 = %01000000 BPP_3 = %10000000 @@ -94,23 +94,23 @@ VFLIP = %00010000 ; Sprite types - redefined to reflect the reality caused by the shadow error TYPE_SHADOW = %00000111 TYPE_XOR = %00000110 -TYPE_NONCOLL = %00000101 ; Non-colliding +TYPE_NONCOLL = %00000101 ; Non-colliding TYPE_NORMAL = %00000100 TYPE_BOUNDARY = %00000011 -TYPE_BSHADOW = %00000010 ; Background shadow -TYPE_BACKNONCOLL = %00000001 ; Background non-colliding +TYPE_BSHADOW = %00000010 ; Background shadow +TYPE_BACKNONCOLL = %00000001 ; Background non-colliding TYPE_BACKGROUND = %00000000 SPRCTL1 = $FC81 LITERAL = %10000000 PACKED = %00000000 -ALGO3 = %01000000 ; Broken, do not set this bit! +ALGO3 = %01000000 ; Broken, do not set this bit! ; Sprite reload mask definitions RELOAD_MASK = %00110000 -RENONE = %00000000 ; Reload nothing -REHV = %00010000 ; Reload hsize, vsize -REHVS = %00100000 ; Reload hsize, vsize, stretch -REHVST = %00110000 ; Reload hsize, vsize, stretch, tilt +RENONE = %00000000 ; Reload nothing +REHV = %00010000 ; Reload hsize, vsize +REHVS = %00100000 ; Reload hsize, vsize, stretch +REHVST = %00110000 ; Reload hsize, vsize, stretch, tilt ; More sprite control 1 bit definitions REUSEPAL = %00001000 SKIP = %00000100 @@ -138,8 +138,9 @@ HOWIE = $FCC4 ; *** Mikey Addresses ; *** -; Mikey Timers +; Mikey timers +; Logical timer names TIMER0 = $FD00 TIMER1 = $FD04 TIMER2 = $FD08 @@ -148,20 +149,20 @@ TIMER4 = $FD10 TIMER5 = $FD14 TIMER6 = $FD18 TIMER7 = $FD1C -HTIMER = $FD00 ; horizontal line timer (timer 0) -VTIMER = $FD08 ; vertical blank timer (timer 2) -STIMER = $FD1C ; sound timer (timer 7) +HTIMER = TIMER0 ; horizontal line timer (timer 0) +VTIMER = TIMER2 ; vertical blank timer (timer 2) +STIMER = TIMER7 ; sound timer (timer 7) -HTIMBKUP = $FD00 ; horizontal line timer (timer 0) +HTIMBKUP = $FD00 ; horizontal line timer (timer 0) HTIMCTLA = $FD01 HTIMCNT = $FD02 HTIMCTLB = $FD03 -VTIMBKUP = $FD08 ; vertical blank timer (timer 2) +VTIMBKUP = $FD08 ; vertical blank timer (timer 2) VTIMCTLA = $FD09 VTIMCNT = $FD0A VTIMCTLB = $FD0B -BAUDBKUP = $FD10 ; serial timer (timer 4) -STIMBKUP = $FD1C ; sound timer (timer 7) +BAUDBKUP = $FD10 ; serial timer (timer 4) +STIMBKUP = $FD1C ; sound timer (timer 7) STIMCTLA = $FD1D STIMCNT = $FD1E STIMCTLB = $FD1F @@ -199,129 +200,227 @@ TIM7CTLA = $FD1D TIM7CNT = $FD1E TIM7CTLB = $FD1F +; Timer offsets +TIM_BACKUP = 0 +TIM_CONTROLA = 1 +TIM_COUNT = 2 +TIM_CONTROLB = 3 + +; TIM_CONTROLA control bits +ENABLE_INT = %10000000 +RESET_DONE = %01000000 +ENABLE_RELOAD = %00010000 +ENABLE_COUNT = %00001000 +AUD_CLOCK_MASK = %00000111 + +; Clock settings +AUD_LINKING = %00000111 +AUD_64 = %00000110 +AUD_32 = %00000101 +AUD_16 = %00000100 +AUD_8 = %00000011 +AUD_4 = %00000010 +AUD_2 = %00000001 +AUD_1 = %00000000 + +; TIM_CONTROLB control bits +TIMER_DONE = %00001000 +LAST_CLOCK = %00000100 +BORROW_IN = %00000010 +BORROW_OUT = %00000001 + ; Mikey Audio -AUDIO0 = $FD20 ; audio channel 0 -AUDIO1 = $FD28 ; audio channel 1 -AUDIO2 = $FD30 ; audio channel 2 -AUDIO3 = $FD38 ; audio channel 3 +AUDIO0 = $FD20 ; audio channel 0 +AUDIO1 = $FD28 ; audio channel 1 +AUDIO2 = $FD30 ; audio channel 2 +AUDIO3 = $FD38 ; audio channel 3 -AUD0VOL = $FD20 -AUD0FEED = $FD21 -AUD0OUT = $FD22 -AUD0SHIFT = $FD23 -AUD0BKUP = $FD24 -AUD0CTLA = $FD25 -AUD0CNT = $FD26 -AUD0CTLB = $FD27 -AUD1VOL = $FD28 -AUD1FEED = $FD29 -AUD1OUT = $FD2A -AUD1SHIFT = $FD2B -AUD1BKUP = $FD2C -AUD1CTLA = $FD2D -AUD1CNT = $FD2E -AUD1CTLB = $FD2F -AUD2VOL = $FD30 -AUD2FEED = $FD31 -AUD2OUT = $FD32 -AUD2SHIFT = $FD33 -AUD2BKUP = $FD34 -AUD2CTLA = $FD35 -AUD2CNT = $FD36 -AUD2CTLB = $FD37 -AUD3VOL = $FD38 -AUD3FEED = $FD39 -AUD3OUT = $FD3A -AUD3SHIFT = $FD3B -AUD3BKUP = $FD3C -AUD3CTLA = $FD3D -AUD3CNT = $FD3E -AUD3CTLB = $FD3F +AUD0VOL = $FD20 +AUD0FEED = $FD21 +AUD0OUT = $FD22 +AUD0SHIFT = $FD23 +AUD0BKUP = $FD24 +AUD0CTLA = $FD25 +AUD0CNT = $FD26 +AUD0CTLB = $FD27 +AUD1VOL = $FD28 +AUD1FEED = $FD29 +AUD1OUT = $FD2A +AUD1SHIFT = $FD2B +AUD1BKUP = $FD2C +AUD1CTLA = $FD2D +AUD1CNT = $FD2E +AUD1CTLB = $FD2F +AUD2VOL = $FD30 +AUD2FEED = $FD31 +AUD2OUT = $FD32 +AUD2SHIFT = $FD33 +AUD2BKUP = $FD34 +AUD2CTLA = $FD35 +AUD2CNT = $FD36 +AUD2CTLB = $FD37 +AUD3VOL = $FD38 +AUD3FEED = $FD39 +AUD3OUT = $FD3A +AUD3SHIFT = $FD3B +AUD3BKUP = $FD3C +AUD3CTLA = $FD3D +AUD3CNT = $FD3E +AUD3CTLB = $FD3F + +; AUD_CONTROL bits are almost identical to TIM_CONTROLA bits. +; See TIM_CONTROLA above for the other definitions +FEEDBACK_7 = %10000000 +ENABLE_INTEGRATE = %00100000 + +; Stereo control registers follow +; Stereo capability does not exist in all Lynxes +; Left and right may be reversed, and if so will be corrected in a later +; release + +ATTENREG0 = $FD40 ; Stereo attenuation registers +ATTENREG1 = $FD41 +ATTENREG2 = $FD42 +ATTENREG3 = $FD43 +LEFT_ATTENMASK = %11110000 +RIGHT_ATTENMASK = %00001111 + +; Bit definitions for MPAN and MSTEREO registers +LEFT3_SELECT = %10000000 +LEFT2_SELECT = %01000000 +LEFT1_SELECT = %00100000 +LEFT0_SELECT = %00010000 +RIGHT3_SELECT = %00001000 +RIGHT2_SELECT = %00000100 +RIGHT1_SELECT = %00000010 +RIGHT0_SELECT = %00000001 + +MPAN = $FD44 MSTEREO = $FD50 -; Mikey Misc - -; Interrupt bits in INTRST and INTSET -TIMER0_INTERRUPT = $01 -TIMER1_INTERRUPT = $02 -TIMER2_INTERRUPT = $04 -TIMER3_INTERRUPT = $08 -TIMER4_INTERRUPT = $10 -TIMER5_INTERRUPT = $20 -TIMER6_INTERRUPT = $40 -TIMER7_INTERRUPT = $80 - -HBL_INTERRUPT = TIMER0_INTERRUPT -VBL_INTERRUPT = TIMER2_INTERRUPT -SERIAL_INTERRUPT = TIMER4_INTERRUPT -SND_INTERRUPT = TIMER7_INTERRUPT +; Mikey interrupts INTRST = $FD80 INTSET = $FD81 -MAGRDY0 = $FD84 -MAGRDY1 = $FD85 -AUDIN = $FD86 -SYSCTL1 = $FD87 -MIKEYHREV = $FD88 -MIKEYSREV = $FD89 +; Interrupt bits in INTRST and INTSET +TIMER0_INTERRUPT = %00000001 +TIMER1_INTERRUPT = %00000010 +TIMER2_INTERRUPT = %00000100 +TIMER3_INTERRUPT = %00001000 +TIMER4_INTERRUPT = %00010000 +TIMER5_INTERRUPT = %00100000 +TIMER6_INTERRUPT = %01000000 +TIMER7_INTERRUPT = %10000000 -IODIR = $FD8A -IODAT = $FD8B +HBL_INTERRUPT = TIMER0_INTERRUPT +VBL_INTERRUPT = TIMER2_INTERRUPT +SERIAL_INTERRUPT = TIMER4_INTERRUPT +SND_INTERRUPT = TIMER7_INTERRUPT + +MAGRDY0 = $FD84 +MAGRDY1 = $FD85 +AUDIN = $FD86 +SYSCTL1 = $FD87 +; SYSCTL1 bit definitions +POWERON = %00000010 +CART_ADDR_STROBE = %00000001 + +MIKEYHREV = $FD88 +MIKEYSREV = $FD89 + +IODIR = $FD8A +IODAT = $FD8B ; IODIR and IODAT bit definitions -AUDIN_BIT = $10 ; Note that there is also the address AUDIN -READ_ENABLE = $10 ; Same bit for AUDIN_BIT -RESTLESS = $08 -NOEXP = $04 ; If set, redeye is not connected -CART_ADDR_DATA = $02 -CART_POWER_OFF = $02 ; Same bit for CART_ADDR_DATA -EXTERNAL_POWER = $01 +AUDIN_BIT = %00010000 ; Note that there is also the address AUDIN +READ_ENABLE = %00010000 ; Same bit for AUDIN_BIT +RESTLESS = %00001000 +NOEXP = %00000100 ; If set, redeye is not connected +CART_ADDR_DATA = %00000010 +CART_POWER_OFF = %00000010 ; Same bit for CART_ADDR_DATA +EXTERNAL_POWER = %00000001 -SERCTL = $FD8C +SERCTL = $FD8C ; SERCTL bit definitions for write operations -TXINTEN = $80 -RXINTEN = $40 -PAREN = $10 -RESETERR = $08 -TXOPEN = $04 -TXBRK = $02 -PAREVEN = $01 +TXINTEN = %10000000 +RXINTEN = %01000000 +PAREN = %00010000 +RESETERR = %00001000 +TXOPEN = %00000100 +TXBRK = %00000010 +PAREVEN = %00000001 ; SERCTL bit definitions for read operations -TXRDY = $80 -RXRDY = $40 -TXEMPTY = $20 -PARERR = $10 -OVERRUN = $08 -FRAMERR = $04 -RXBRK = $02 -PARBIT = $01 +TXRDY = %10000000 +RXRDY = %01000000 +TXEMPTY = %00100000 +PARERR = %00010000 +OVERRUN = %00001000 +FRAMERR = %00000100 +RXBRK = %00000010 +PARBIT = %00000001 -SERDAT = $FD8D -SDONEACK = $FD90 -CPUSLEEP = $FD91 -DISPCTL = $FD92 -PBKUP = $FD93 -DISPADRL = $FD94 -DISPADRH = $FD95 -MTEST0 = $FD9C -MTEST1 = $FD9D -MTEST2 = $FD9E -PALETTE = $FDA0 ; hardware rgb palette -GCOLMAP = $FDA0 ; hardware rgb palette (green) -RBCOLMAP = $FDB0 ; hardware rgb palette (red-blue) +SERDAT = $FD8D +SDONEACK = $FD90 +CPUSLEEP = $FD91 +DISPCTL = $FD92 +; DISPCTL bit definitions +DISP_COLOR = %10000000 ; must be set to 1 +DISP_FOURBIT = %01000000 ; must be set to 1 +DISP_FLIP = %00100000 +DMA_ENABLE = %00010000 ; must be set to 1 +PBKUP = $FD93 +DISPADRL = $FD94 +DISPADRH = $FD95 -; *** -; *** Misc Hardware + 6502 vectors -; *** +MTEST0 = $FD9C +; MTEST0 bit definitions +AT_CNT16 = %10000000 +AT_TEST = %01000000 +XCLKEN = %00100000 +UART_TURBO = %00010000 +ROM_SEL = %00001000 +ROM_TEST = %00000100 +M_TEST = %00000010 +CPU_TEST = %00000001 -MAPCTL = $FFF9 -VECTORS = $FFFB -INTVECTL = $FFFE -INTVECTH = $FFFF -RSTVECTL = $FFFC -RSTVECTH = $FFFD -NMIVECTL = $FFFA -NMIVECTH = $FFFB +MTEST1 = $FD9D +; MTEST1 bit definitions +P_CNT16 = %01000000 +REF_CNT16 = %00100000 +VID_TRIG = %00010000 +REF_TRIG = %00001000 +VID_DMA_DIS = %00000100 +REF_FAST = %00000010 +REF_DIS = %00000001 +MTEST2 = $FD9E +; MTEST2 bit definitions +V_STROBE = %00010000 +V_ZERO = %00001000 +H_120 = %00000100 +H_ZERO = %00000010 +V_BLANKEF = %00000001 + +PALETTE = $FDA0 ; hardware rgb palette +GCOLMAP = $FDA0 ; hardware rgb palette (green) +RBCOLMAP = $FDB0 ; hardware rgb palette (red-blue) + +; Memory mapping control and 6502 vectors + +MAPCTL = $FFF9 +; MAPCTL bit definitions +TURBO_DISABLE = %10000000 +VECTOR_SPACE = %00001000 ; 1 maps RAM into specified space +ROM_SPACE = %00000100 +MIKEY_SPACE = %00000010 +SUZY_SPACE = %00000001 + +VECTORS = $FFFB +INTVECTL = $FFFE +INTVECTH = $FFFF +RSTVECTL = $FFFC +RSTVECTH = $FFFD +NMIVECTL = $FFFA +NMIVECTH = $FFFB diff --git a/include/_mikey.h b/include/_mikey.h index b9b7f6906..9a50745b2 100644 --- a/include/_mikey.h +++ b/include/_mikey.h @@ -27,7 +27,7 @@ #ifndef __MIKEY_H #define __MIKEY_H -/* timer structure */ +/* Timer structure */ typedef struct _mikey_timer { unsigned char reload; unsigned char control; @@ -39,7 +39,7 @@ typedef struct _mikey_all_timers { struct _mikey_timer timer[8]; } _mikey_all_timers; -/* audio channel structure */ +/* Audio channel structure */ typedef struct _mikey_audio { unsigned char volume; unsigned char feedback; @@ -53,54 +53,213 @@ typedef struct _mikey_audio { /* Define a structure with the mikey register offsets */ struct __mikey { - struct _mikey_timer timer0; // 0xFD00 - struct _mikey_timer timer1; // 0xFD04 - struct _mikey_timer timer2; // 0xFD08 - struct _mikey_timer timer3; // 0xFD0C - struct _mikey_timer timer4; // 0xFD10 - struct _mikey_timer timer5; // 0xFD14 - struct _mikey_timer timer6; // 0xFD18 - struct _mikey_timer timer7; // 0xFD1C - struct _mikey_audio channel_a; // 0xFD20 - struct _mikey_audio channel_b; // 0xFD28 - struct _mikey_audio channel_c; // 0xFD30 - struct _mikey_audio channel_d; // 0xFD38 - unsigned char attena; // 0xFD40 ?? not yet allocated? - unsigned char attenb; // 0xFD41 | - unsigned char attenc; // 0xFD42 | - unsigned char attend; // 0xFD43 | - unsigned char panning; // 0xFD44 | - unsigned char unused0[11]; // 0xFD45 - 0xFD4F not used - unsigned char mstereo; // 0xFD50 stereo control bits - unsigned char unused1[47]; // 0xFD51 - 0xFD7F not used - unsigned char intrst; // 0xFD80 interrupt poll 0 - unsigned char intset; // 0xFD81 interrupt poll 1 - unsigned char unused2[2]; // 0xFD82 - 0xFD83 not used - unsigned char magrdy0; // 0xFD84 mag tape channel0 ready bit - unsigned char magrdy1; // 0xFD85 mag tape channel1 ready bit - unsigned char audin; // 0xFD86 audio in - unsigned char sysctl1; // 0xFD87 control bits - unsigned char mikeyrev; // 0xFD88 mikey hardware rev - unsigned char mikeysrev; // 0xFD89 mikey software rev - unsigned char iodir; // 0xFD8A parallel i/o data dir - unsigned char iodat; // 0xFD8B parallel data - unsigned char serctl; // 0xFD8C serial control register - unsigned char serdat; // 0xFD8D serial data - unsigned char unused3[2]; // 0xFD8E - 0xFD8F not used - unsigned char sdoneack; // 0xFD90 suzy done acknowledge - unsigned char cpusleep; // 0xFD91 cpu bus request disable - unsigned char dispctl; // 0xFD92 video bus request enable, viddma - unsigned char pkbkup; // 0xFD93 magic 'P' count - unsigned char *scrbase; // 0xFD94 start address of video display - unsigned char unused4[6]; // 0xFD96 - 0xFD9B not used - unsigned char mtest0; // 0xFD9C - unsigned char mtest1; // 0xFD9D - unsigned char mtest2; // 0xFD9E - unsigned char unused5; // 0xFD9F not used - unsigned char palette[32]; // 0xFDA0 - 0xFDBF palette 32 bytes - // 0xFDC0 - 0xFDFF not used + struct _mikey_timer timer0; // 0xFD00 + struct _mikey_timer timer1; // 0xFD04 + struct _mikey_timer timer2; // 0xFD08 + struct _mikey_timer timer3; // 0xFD0C + struct _mikey_timer timer4; // 0xFD10 + struct _mikey_timer timer5; // 0xFD14 + struct _mikey_timer timer6; // 0xFD18 + struct _mikey_timer timer7; // 0xFD1C + struct _mikey_audio channel_a; // 0xFD20 + struct _mikey_audio channel_b; // 0xFD28 + struct _mikey_audio channel_c; // 0xFD30 + struct _mikey_audio channel_d; // 0xFD38 + unsigned char attena; // 0xFD40 ?? not yet allocated? + unsigned char attenb; // 0xFD41 | + unsigned char attenc; // 0xFD42 | + unsigned char attend; // 0xFD43 | + unsigned char panning; // 0xFD44 | + unsigned char unused0[11]; // 0xFD45 - 0xFD4F not used + unsigned char mstereo; // 0xFD50 stereo control bits + unsigned char unused1[47]; // 0xFD51 - 0xFD7F not used + unsigned char intrst; // 0xFD80 interrupt poll 0 + unsigned char intset; // 0xFD81 interrupt poll 1 + unsigned char unused2[2]; // 0xFD82 - 0xFD83 not used + unsigned char magrdy0; // 0xFD84 mag tape channel0 ready bit + unsigned char magrdy1; // 0xFD85 mag tape channel1 ready bit + unsigned char audin; // 0xFD86 audio in + unsigned char sysctl1; // 0xFD87 control bits + unsigned char mikeyrev; // 0xFD88 mikey hardware rev + unsigned char mikeysrev; // 0xFD89 mikey software rev + unsigned char iodir; // 0xFD8A parallel i/o data dir + unsigned char iodat; // 0xFD8B parallel data + unsigned char serctl; // 0xFD8C serial control register + unsigned char serdat; // 0xFD8D serial data + unsigned char unused3[2]; // 0xFD8E - 0xFD8F not used + unsigned char sdoneack; // 0xFD90 suzy done acknowledge + unsigned char cpusleep; // 0xFD91 cpu bus request disable + unsigned char dispctl; // 0xFD92 video bus request enable, viddma + unsigned char pkbkup; // 0xFD93 magic 'P' count + unsigned char *scrbase; // 0xFD94 start address of video display + unsigned char unused4[6]; // 0xFD96 - 0xFD9B not used + unsigned char mtest0; // 0xFD9C + unsigned char mtest1; // 0xFD9D + unsigned char mtest2; // 0xFD9E + unsigned char unused5; // 0xFD9F not used + unsigned char palette[32]; // 0xFDA0 - 0xFDBF palette 32 bytes + unsigned char unused6[64]; // 0xFDC0 - 0xFDFF not used + unsigned char bootrom[504]; // 0xFE00 - 0xFFD8 boot rom + unsigned char reserved; // 0xFFD8 reserved for future hardware + unsigned char mapctl; // 0xFFF9 map control register + struct { + unsigned char *nmi; // 0xFFFA NMI vector + unsigned char *reset; // 0xFFFB reset vector + unsigned char *irq; // 0xFFFC IRQ vector + } vectors; }; +// TIM_CONTROLA control bit definitions +enum { + ENABLE_INT = 0x80, + RESET_DONE = 0x40, + ENABLE_RELOAD = 0x10, + ENABLE_COUNT = 0x08 +}; + +// AUD_CONTROL control bit definitions +enum { + FEEDBACK_7 = 0x80, + ENABLE_INTEGRATE = 0x20 +}; + +// Audio and timer clock settings for source period +enum { + AUD_LINKING = 0x07, + AUD_64 = 0x06, + AUD_32 = 0x05, + AUD_16 = 0x04, + AUD_8 = 0x03, + AUD_4 = 0x02, + AUD_2 = 0x01, + AUD_1 = 0x00 +}; + +// TIM_CONTROLB control bit definitions +enum { + TIMER_DONE = 0x08, + LAST_CLOCK = 0x04, + BORROW_IN = 0x02, + BORROW_OUT = 0x01 +}; + +// MPAN and MSTEREO registers bit definitions +enum { + LEFT3_SELECT = 0x80, + LEFT2_SELECT = 0x40, + LEFT1_SELECT = 0x20, + LEFT0_SELECT = 0x10, + RIGHT3_SELECT = 0x08, + RIGHT2_SELECT = 0x04, + RIGHT1_SELECT = 0x02, + RIGHT0_SELECT = 0x01, + LEFT_ATTENMASK = 0xF0, + RIGHT_ATTENMASK = 0x0F +}; + +// Interrupt Reset and Set bit definitions +enum { + TIMER7_INT = 0x80, + TIMER6_INT = 0x40, + TIMER5_INT = 0x20, + TIMER4_INT = 0x10, + TIMER3_INT = 0x08, + TIMER2_INT = 0x04, + TIMER1_INT = 0x02, + TIMER0_INT = 0x01, + SERIAL_INT = TIMER4_INT, + VERTICAL_INT = TIMER2_INT, + HORIZONTAL_INT = TIMER0_INT +}; + +// SYSCTL1 bit definitions +enum { + POWERON = 0x02, + CART_ADDR_STROBE = 0x01 +}; + +// IODIR and IODAT bit definitions +enum { + AUDIN_BIT = 0x10, // different from AUDIN address + READ_ENABLE = 0x10, // same bit for AUDIN_BIT + RESTLESS = 0x08, + NOEXP = 0x04, // if set, redeye is not connected + CART_ADDR_DATA = 0x02, // + CART_POWER_OFF = 0x02, // same bit for CART_ADDR_DATA + EXTERNAL_POWER = 0x01 +}; + +// SERCTL bit definitions for write operations +enum { + TXINTEN = 0x80, + RXINTEN = 0x40, + PAREN = 0x10, + RESETERR = 0x08, + TXOPEN = 0x04, + TXBRK = 0x02, + PAREVEN = 0x01 +}; + +// SERCTL bit definitions for read operations +enum { + TXRDY = 0x80, + RXRDY = 0x40, + TXEMPTY = 0x20, + PARERR = 0x10, + OVERRUN = 0x08, + FRAMERR = 0x04, + RXBRK = 0x02, + PARBIT = 0x01 +}; + +// DISPCTL bit definitions +enum { + DISP_COLOR = 0x08, // must be set to 1 + DISP_FOURBIT = 0x04, // must be set to 1 + DISP_FLIP = 0x02, // + DMA_ENABLE = 0x01 // must be set to 1 +}; + +// MTEST0 bit definitions +enum { + AT_CNT16 = 0x80, + AT_TEST = 0x40, + XCLKEN = 0x20, + UART_TURBO = 0x10, + ROM_SEL = 0x08, + ROM_TEST = 0x04, + M_TEST = 0x02, + CPU_TEST = 0x01 +}; + +// MTEST1 bit definitions +enum { + P_CNT16 = 0x40, + REF_CNT16 = 0x20, + VID_TRIG = 0x10, + REF_TRIG = 0x08, + VID_DMA_DIS = 0x04, + REF_FAST = 0x02, + REF_DIS = 0x01 +}; + +// MTEST2 bit definitions +enum { + V_STROBE = 0x10, + V_ZERO = 0x08, + H_120 = 0x04, + H_ZERO = 0x02, + V_BLANKEF = 0x01 +}; + +// MAPCTL bit definitions +enum { + TURBO_DISABLE = 0x80, + VECTOR_SPACE = 0x08, + ROM_SPACE = 0x04, + MIKEY_SPACE = 0x02, + SUZY_SPACE = 0x01 +}; #endif From 3553975b025f2524ec1b9802520c18045f17a799 Mon Sep 17 00:00:00 2001 From: Alex Thissen Date: Fri, 9 Aug 2024 13:53:41 +0200 Subject: [PATCH 02/11] Math improvements to Suzy include file --- include/_suzy.h | 69 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 17 deletions(-) diff --git a/include/_suzy.h b/include/_suzy.h index 8ab7f68dd..c2c9de49c 100644 --- a/include/_suzy.h +++ b/include/_suzy.h @@ -242,10 +242,38 @@ typedef struct PENPAL_1 { #define MIKEYSPACE 0x02 #define SUZYSPACE 0x01 +// Structures for math registers +struct _math_unsigned_multiply { + unsigned int factor1; // 0xFC52 - 0xFC53 + unsigned int factor2; // 0xFC54 - 0xFC55 write starts multiply + unsigned char unused2[10]; // 0xFC56 - 0xFC5F do not use + unsigned long product; // 0xFC60 - 0xFC63 + unsigned char unused3[8]; // 0xFC64 - 0xFC6B do not use + unsigned long accumulate; // 0xFC6C - 0xFC6F +}; + +struct _math_signed_multiply { + int factor1; // 0xFC52 - 0xFC53 + int factor2; // 0xFC54 - 0xFC55 write starts multiply + unsigned char unused2[10]; // 0xFC56 - 0xFC5F do not use + long product; // 0xFC60 - 0xFC63 + unsigned char unused3[8]; // 0xFC64 - 0xFC6B do not use + long accumulate; // 0xFC6C - 0xFC6F +}; + +struct _math_divide { + unsigned long quotient; // 0xFC52 - 0xFC55 + unsigned int divisor; // 0xFC56 - 0xFC57 + unsigned char unused2[8]; // 0xFC58 - 0xFC5F do not use + unsigned int dividend2; // 0xFC60 - 0xFC61 + unsigned int dividend1; // 0xFC62 - 0xFC63 write starts divide + unsigned char unused3[8]; // 0xFC64 - 0xFC6B do not use + unsigned long remainder; // 0xFC6C - 0xFC6F +}; /* Suzy Hardware Registers */ struct __suzy { - unsigned int tmpadr; // 0xFC00 Temporary address + unsigned char *tmpadr; // 0xFC00 Temporary address unsigned int tiltacc; // 0xFC02 Tilt accumulator unsigned int hoff; // 0xFC04 Offset to H edge of screen unsigned int voff; // 0xFC06 Offset to V edge of screen @@ -271,22 +299,29 @@ struct __suzy { unsigned char *procaddr; // 0xFC2E address of current spr data proc unsigned char unused0[32]; // 0xFC30 - 0xFC4F reserved/unused unsigned char unused1[2]; // 0xFC50 - 0xFC51 do not use - unsigned char mathd; // 0xFC52 - unsigned char mathc; // 0xFC53 - unsigned char mathb; // 0xFC54 - unsigned char matha; // 0xFC55 - unsigned char mathp; // 0xFC56 - unsigned char mathn; // 0xFC57 - unsigned char unused2[8]; // 0xFC58 - 0xFC5F do not use - unsigned char mathh; // 0xFC60 - unsigned char mathg; // 0xFC61 - unsigned char mathf; // 0xFC62 - unsigned char mathe; // 0xFC63 - unsigned char unused3[8]; // 0xFC64 - 0xFC6B do not use - unsigned char mathm; // 0xFC6C - unsigned char mathl; // 0xFC6D - unsigned char mathk; // 0xFC6E - unsigned char mathj; // 0xFC6F + union { + struct { + unsigned char mathd; // 0xFC52 + unsigned char mathc; // 0xFC53 + unsigned char mathb; // 0xFC54 + unsigned char matha; // 0xFC55 write starts a multiply operation + unsigned char mathp; // 0xFC56 + unsigned char mathn; // 0xFC57 + unsigned char unused2[8]; // 0xFC58 - 0xFC5F do not use + unsigned char mathh; // 0xFC60 + unsigned char mathg; // 0xFC61 + unsigned char mathf; // 0xFC62 + unsigned char mathe; // 0xFC63 write starts a divide operation + unsigned char unused3[8]; // 0xFC64 - 0xFC6B do not use + unsigned char mathm; // 0xFC6C + unsigned char mathl; // 0xFC6D + unsigned char mathk; // 0xFC6E + unsigned char mathj; // 0xFC6F + }; + struct _math_unsigned_multiply unsigned_multiply; + struct _math_signed_multiply signed_multiply; + struct _math_divide divide; + }; unsigned char unused4[16]; // 0xFC70 - 0xFC7F do not use unsigned char sprctl0; // 0xFC80 sprite control bits 0 unsigned char sprctl1; // 0xFC81 sprite control bits 1 From 7150fdf4b9608a4377f1c5c26e4c0a66f9faae54 Mon Sep 17 00:00:00 2001 From: Alex Thissen Date: Fri, 9 Aug 2024 14:48:13 +0200 Subject: [PATCH 03/11] Enumerations and math structures for Suzy --- include/_suzy.h | 192 +++++++++++++++++++++++++----------------------- include/lynx.h | 177 +++++++++++++------------------------------- 2 files changed, 152 insertions(+), 217 deletions(-) diff --git a/include/_suzy.h b/include/_suzy.h index c2c9de49c..29a263880 100644 --- a/include/_suzy.h +++ b/include/_suzy.h @@ -24,73 +24,62 @@ /* */ /*****************************************************************************/ - #ifndef __SUZY_H #define __SUZY_H -/* Joypad $FCB0 */ -#define JOYPAD_RIGHT 0x10 -#define JOYPAD_LEFT 0x20 -#define JOYPAD_DOWN 0x40 -#define JOYPAD_UP 0x80 -#define BUTTON_OPTION1 0x08 -#define BUTTON_OPTION2 0x04 -#define BUTTON_INNER 0x02 -#define BUTTON_OUTER 0x01 +// JOYSTICK bit definitions +enum { + JOYPAD_RIGHT = 0x10, + JOYPAD_LEFT = 0x20, + JOYPAD_DOWN = 0x40, + JOYPAD_UP = 0x80, + BUTTON_OPTION1 = 0x08, + BUTTON_OPTION2 = 0x04, + BUTTON_INNER = 0x02, + BUTTON_OUTER = 0x01 +}; -/* Switches $FCB1 */ -#define BUTTON_PAUSE 0x01 +// SWITCHES bit definitions +enum { + CART1_IO_INACTIVE = 0x04, + CART0_IO_INACTIVE = 0x02, + BUTTON_PAUSE = 0x01 +}; +// SPRCTL0 bit definitions +enum { + BPP_4 = 0xC0, + BPP_3 = 0x80, + BPP_2 = 0x40, + BPP_1 = 0x00, + HFLIP = 0x20, + VFLIP = 0x10, + TYPE_SHADOW = 0x07, + TYPE_XOR = 0x06, + TYPE_NONCOLL = 0x05, + TYPE_NORMAL = 0x04, + TYPE_BOUNDARY = 0x03, + TYPE_BSHADOW = 0x02, + TYPE_BACKNONCOLL = 0x01, + TYPE_BACKGROUND = 0x00 +}; -/* Hardware Math */ -#define FACTOR_A *(unsigned int *) 0xFC54 -#define FACTOR_B *(unsigned int *) 0xFC52 -#define PRODUCT0 *(unsigned int *) 0xFC60 -#define PRODUCT1 *(unsigned int *) 0xFC62 -#define PRODUCT *(long *) 0xFC60 +// SPRCTL1 bit definitions +enum { + LITERAL = 0x80, + PACKED = 0x00, + ALGO3 = 0x40, + RENONE = 0x00, + REHV = 0x10, + REHVS = 0x20, + REHVST = 0x30, + REUSEPAL = 0x08, + SKIP = 0x04, + DRAWUP = 0x02, + DRAWLEFT = 0x01 +}; -#define DIVIDEND0 *(unsigned int *) 0xFC60 -#define DIVIDEND1 *(unsigned int *) 0xFC62 -#define DIVIDEND *(long *) 0xFC60 -#define DIVISOR *(unsigned int *) 0xFC56 -#define QUOTIENT0 *(unsigned int *) 0xFC52 -#define QUOTIENT1 *(unsigned int *) 0xFC54 -#define QUOTIENT *(long *) 0xFC52 -#define REMAINDER0 *(unsigned int *) 0xFC6C -#define REMAINDER1 *(unsigned int *) 0xFC6E -#define REMAINDER *(long *) 0xFC6C - - -/* Sprite control block (SCB) defines */ - -/* SPRCTL0 $FC80 */ -#define BPP_4 0xC0 -#define BPP_3 0x80 -#define BPP_2 0x40 -#define BPP_1 0x00 -#define HFLIP 0x20 -#define VFLIP 0x10 -#define TYPE_SHADOW 0x07 -#define TYPE_XOR 0x06 -#define TYPE_NONCOLL 0x05 -#define TYPE_NORMAL 0x04 -#define TYPE_BOUNDARY 0x03 -#define TYPE_BSHADOW 0x02 -#define TYPE_BACKNONCOLL 0x01 -#define TYPE_BACKGROUND 0x00 - -/* SPRCTL1 $FC81 */ -#define LITERAL 0x80 -#define PACKED 0x00 -#define ALGO3 0x40 -#define RENONE 0x00 -#define REHV 0x10 -#define REHVS 0x20 -#define REHVST 0x30 -#define REUSEPAL 0x08 -#define SKIP 0x04 -#define DRAWUP 0x02 -#define DRAWLEFT 0x01 +// Sprite control block (SCB) definitions typedef struct SCB_REHVST_PAL { // SCB with all attributes unsigned char sprctl0; @@ -210,37 +199,33 @@ typedef struct PENPAL_1 { unsigned char penpal[1]; } PENPAL_1; -/* Misc system defines */ +// SPRGO bit definitions +enum { + SPRITE_GO = 0x01, // sprite process start bit + EVER_ON = 0x04 // everon detector enable +}; -/* SPRGO $FC91 */ -#define EVER_ON 0x04 -#define SPRITE_GO 0x01 - -/* SPRSYS (write) $FC92 */ -#define SIGNMATH 0x80 -#define ACCUMULATE 0x40 -#define NO_COLLIDE 0x20 -#define VSTRETCH 0x10 -#define LEFTHAND 0x08 -#define CLR_UNSAFE 0x04 -#define SPRITESTOP 0x02 - -/* SPRSYS (read) $FC92 */ -#define MATHWORKING 0x80 -#define MATHWARNING 0x40 -#define MATHCARRY 0x20 -#define VSTRETCHING 0x10 -#define LEFTHANDED 0x08 -#define UNSAFE_ACCESS 0x04 -#define SPRITETOSTOP 0x02 -#define SPRITEWORKING 0x01 - -/* MAPCTL $FFF9 */ -#define HIGHSPEED 0x80 -#define VECTORSPACE 0x08 -#define ROMSPACE 0x04 -#define MIKEYSPACE 0x02 -#define SUZYSPACE 0x01 +// SPRSYS bit definitions for write operations +enum { + SIGNMATH = 0x80, // signed math + ACCUMULATE = 0x40, // accumulate multiplication results + NO_COLLIDE = 0x20, // do not collide with any sprites (also SPRCOLL bit definition) + VSTRETCH = 0x10, // stretch v + LEFTHAND = 0x08, + CLR_UNSAFE = 0x04, // unsafe access reset + SPRITESTOP = 0x02 // request to stop sprite process +}; +// SPRSYS bit definitions for read operations +enum { + MATHWORKING = 0x80, // math operation in progress + MATHWARNING = 0x40, // accumulator overflow on multiple or divide by zero + MATHCARRY = 0x20, // last carry bit + VSTRETCHING = 0x10, + LEFTHANDED = 0x08, + UNSAFE_ACCESS = 0x04, // unsafe access performed + SPRITETOSTOP = 0x02, // requested to stop + SPRITEWORKING = 0x01 // sprite process is active +}; // Structures for math registers struct _math_unsigned_multiply { @@ -348,6 +333,31 @@ struct __suzy { // 0xFCC5 - 0xFCFF unused }; +// Deprecated definitions + +/* Hardware Math */ +#define FACTOR_A *(unsigned int *) 0xFC54 +#define FACTOR_B *(unsigned int *) 0xFC52 +#define PRODUCT0 *(unsigned int *) 0xFC60 +#define PRODUCT1 *(unsigned int *) 0xFC62 +#define PRODUCT *(long *) 0xFC60 + +#define DIVIDEND0 *(unsigned int *) 0xFC60 +#define DIVIDEND1 *(unsigned int *) 0xFC62 +#define DIVIDEND *(long *) 0xFC60 +#define DIVISOR *(unsigned int *) 0xFC56 +#define QUOTIENT0 *(unsigned int *) 0xFC52 +#define QUOTIENT1 *(unsigned int *) 0xFC54 +#define QUOTIENT *(long *) 0xFC52 +#define REMAINDER0 *(unsigned int *) 0xFC6C +#define REMAINDER1 *(unsigned int *) 0xFC6E +#define REMAINDER *(long *) 0xFC6C + +/* MAPCTL $FFF9 */ +#define HIGHSPEED 0x80 +#define VECTORSPACE 0x08 +#define ROMSPACE 0x04 +#define MIKEYSPACE 0x02 +#define SUZYSPACE 0x01 #endif - diff --git a/include/lynx.h b/include/lynx.h index 41dc5acb3..e2c0c503f 100644 --- a/include/lynx.h +++ b/include/lynx.h @@ -31,27 +31,15 @@ /* */ /*****************************************************************************/ - - #ifndef _LYNX_H #define _LYNX_H - - /* Check for errors */ #if !defined(__LYNX__) # error This module may only be used when compiling for the Lynx game console! #endif - - -/*****************************************************************************/ -/* Data */ -/*****************************************************************************/ - - - -/* Color defines */ +/* Color definitions */ #define COLOR_TRANSPARENT 0x00 #define COLOR_BLACK 0x01 #define COLOR_RED 0x02 @@ -88,6 +76,56 @@ #define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE #define TGI_COLOR_WHITE COLOR_WHITE +/* No support for dynamically loadable drivers */ +#define DYN_DRV 0 + +// Addresses of static drivers +extern void lynx_stdjoy_joy[]; // Referred to by joy_static_stddrv[] +extern void lynx_comlynx_ser[]; // Referred to by ser_static_stddrv[] +extern void lynx_160_102_16_tgi[]; // Referred to by tgi_static_stddrv[] + +// Sound support +void lynx_snd_init (void); // Initialize the sound driver +void lynx_snd_pause (void); // Pause sound +void lynx_snd_continue (void); // Continue sound after pause +void __fastcall__ lynx_snd_play (unsigned char channel, unsigned char *music); // Play tune on channel +void lynx_snd_stop (void); // Stop sound on all channels +void __fastcall__ lynx_snd_stop_channel (unsigned char channel); // Stop sound on all channels +unsigned char lynx_snd_active(void); // Show which channels are active + +// Cartridge access +void __fastcall__ lynx_load (int file_number); // Load a file into RAM using a zero-based index +void __fastcall__ lynx_exec (int file_number); // Load a file into ram and execute it + +// EEPROM access +unsigned __fastcall__ lynx_eeprom_read (unsigned char cell); // Read a 16 bit word from the given address +unsigned __fastcall__ lynx_eeprom_write (unsigned char cell, unsigned val); // Write the word at the given address +void __fastcall__ lynx_eeprom_erase (unsigned char cell); // Clear the word at the given address +unsigned __fastcall__ lynx_eeread (unsigned cell); // Read a 16 bit word from the given address 93C46, 93C66 or 93C86 +unsigned __fastcall__ lynx_eewrite (unsigned cell, unsigned val); // Write the word at the given address 93C46, 93C66 or 93C86 + +// TGI extras +#define tgi_sprite(spr) tgi_ioctl(0, spr) +#define tgi_flip() tgi_ioctl(1, (void*)0) +#define tgi_setbgcolor(bgcol) tgi_ioctl(2, (void*)(bgcol)) +#define tgi_setframerate(rate) tgi_ioctl(3, (void*)(rate)) +#define tgi_busy() tgi_ioctl(4, (void*)0) +#define tgi_updatedisplay() tgi_ioctl(4, (void*)1) +#define tgi_setcollisiondetection(active) tgi_ioctl(5, (void*)(active)) + +/* Hardware definitions */ +#include <_mikey.h> +#define MIKEY (*(struct __mikey *)0xFD00) + +#define _MIKEY_TIMERS (*(struct _mikey_all_timers *) 0xFD00) // mikey_timers[8] +#define _HBL_TIMER (*(struct _mikey_timer *) 0xFD00) // timer0 (HBL) +#define _VBL_TIMER (*(struct _mikey_timer *) 0xFD08) // timer2 (VBL) +#define _UART_TIMER (*(struct _mikey_timer *) 0xFD14) // timer4 (UART) +#define _VIDDMA (*(unsigned int *) 0xFD92) // dispctl/viddma + +#include <_suzy.h> +#define SUZY (*(volatile struct __suzy*)0xFC00) + /* Masks for joy_read */ #define JOY_UP_MASK 0x80 #define JOY_DOWN_MASK 0x40 @@ -102,118 +140,5 @@ #define JOY_BTN_A(v) ((v) & JOY_BTN_A_MASK) #define JOY_BTN_B(v) ((v) & JOY_BTN_B_MASK) -/* No support for dynamically loadable drivers */ -#define DYN_DRV 0 - - - -/*****************************************************************************/ -/* Variables */ -/*****************************************************************************/ - - - -/* The addresses of the static drivers */ -extern void lynx_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */ -extern void lynx_comlynx_ser[]; /* Referred to by ser_static_stddrv[] */ -extern void lynx_160_102_16_tgi[]; /* Referred to by tgi_static_stddrv[] */ - - - -/*****************************************************************************/ -/* Sound support */ -/*****************************************************************************/ - - - -void lynx_snd_init (void); -/* Initialize the sound driver */ - -void lynx_snd_pause (void); -/* Pause sound */ - -void lynx_snd_continue (void); -/* Continue sound after pause */ - -void __fastcall__ lynx_snd_play (unsigned char channel, unsigned char *music); -/* Play tune on channel */ - -void lynx_snd_stop (void); -/* Stop sound on all channels */ - -void __fastcall__ lynx_snd_stop_channel (unsigned char channel); -/* Stop sound on all channels */ - -unsigned char lynx_snd_active(void); -/* Show which channels are active */ - - - -/*****************************************************************************/ -/* Accessing the cart */ -/*****************************************************************************/ - - - -void __fastcall__ lynx_load (int fileno); -/* Load a file into ram. The first entry is fileno=0. */ - -void __fastcall__ lynx_exec (int fileno); -/* Load a file into ram and execute it. */ - - - -/*****************************************************************************/ -/* Accessing the EEPROM */ -/*****************************************************************************/ - - - -unsigned __fastcall__ lynx_eeprom_read (unsigned char cell); -/* Read a 16 bit word from the given address */ - -unsigned __fastcall__ lynx_eeprom_write (unsigned char cell, unsigned val); -/* Write the word at the given address */ - -void __fastcall__ lynx_eeprom_erase (unsigned char cell); -/* Clear the word at the given address */ - -unsigned __fastcall__ lynx_eeread (unsigned cell); -/* Read a 16 bit word from the given address 93C46 93C66 or 93C86*/ - -unsigned __fastcall__ lynx_eewrite (unsigned cell, unsigned val); -/* Write the word at the given address 93C46 93C66 or 93C86*/ - - - -/*****************************************************************************/ -/* TGI extras */ -/*****************************************************************************/ - - - -#define tgi_sprite(spr) tgi_ioctl(0, spr) -#define tgi_flip() tgi_ioctl(1, (void*)0) -#define tgi_setbgcolor(bgcol) tgi_ioctl(2, (void*)(bgcol)) -#define tgi_setframerate(rate) tgi_ioctl(3, (void*)(rate)) -#define tgi_busy() tgi_ioctl(4, (void*)0) -#define tgi_updatedisplay() tgi_ioctl(4, (void*)1) -#define tgi_setcollisiondetection(active) tgi_ioctl(5, (void*)(active)) - -/* Define Hardware */ -#include <_mikey.h> -#define MIKEY (*(struct __mikey *)0xFD00) - -#define _MIKEY_TIMERS (*(struct _mikey_all_timers *) 0xFD00) // mikey_timers[8] -#define _HBL_TIMER (*(struct _mikey_timer *) 0xFD00) // timer0 (HBL) -#define _VBL_TIMER (*(struct _mikey_timer *) 0xFD08) // timer2 (VBL) -#define _UART_TIMER (*(struct _mikey_timer *) 0xFD14) // timer4 (UART) -#define _VIDDMA (*(unsigned int *) 0xFD92) // dispctl/viddma - -#include <_suzy.h> -#define SUZY (*(struct __suzy*)0xFC00) - - - /* End of lynx.h */ #endif From abcb073a5a30ddfbae8ddcdb1a82a42e047f18b4 Mon Sep 17 00:00:00 2001 From: Alex Thissen Date: Fri, 9 Aug 2024 15:10:30 +0200 Subject: [PATCH 04/11] Bit definitions for Suzy --- asminc/lynx.inc | 192 ++++++++++++++++++++++++++++-------------------- 1 file changed, 113 insertions(+), 79 deletions(-) diff --git a/asminc/lynx.inc b/asminc/lynx.inc index d6a8cd70a..458cd650f 100644 --- a/asminc/lynx.inc +++ b/asminc/lynx.inc @@ -79,7 +79,7 @@ MATHL = $FC6D MATHK = $FC6E MATHJ = $FC6F -; Suzy Misc +; Suzy sprite engine SPRCTL0 = $FC80 ; Sprite bits-per-pixel definitions @@ -117,15 +117,53 @@ SKIP = %00000100 DRAWUP = %00000010 DRAWLEFT = %00000001 -SPRCOLL = $FC82 -SPRINIT = $FC83 -SUZYHREV = $FC88 -SUZYSREV = $FC89 -SUZYBUSEN = $FC90 -SPRGO = $FC91 -SPRSYS = $FC92 -JOYSTICK = $FCB0 +SPRCOLL = $FC82 +SPRINIT = $FC83 +SUZYHREV = $FC88 +SUZYSREV = $FC89 +SUZYBUSEN = $FC90 + +SPRGO = $FC91 +; SPRGO bit definitions +SPRITE_GO = %00000001 ; sprite process start bit +EVER_ON = %00000100 ; everon detector enable + +SPRSYS = $FC92 +; SPRSYS bit definitions for write operations +SIGNMATH = 0x80 ; signed math +ACCUMULATE = 0x40 ; accumulate multiplication results +NO_COLLIDE = 0x20 ; do not collide with any sprites (also SPRCOLL bit definition) +VSTRETCH = 0x10 ; stretch v +LEFTHAND = 0x08 +CLR_UNSAFE = 0x04 ; unsafe access reset +SPRITESTOP = 0x02 ; request to stop sprite process +; SPRSYS bit definitions for read operations +MATHWORKING = 0x80 ; math operation in progress +MATHWARNING = 0x40 ; accumulator overflow on multiple or divide by zero +MATHCARRY = 0x20 ; last carry bit +VSTRETCHING = 0x10 +LEFTHANDED = 0x08 +UNSAFE_ACCESS = 0x04 ; unsafe access performed +SPRITETOSTOP = 0x02 ; requested to stop +SPRITEWORKING = 0x01 ; sprite process is active + +JOYSTICK = $FCB0 +; JOYSTICK bit definitions +JOYPAD_UP = 0x80 +JOYPAD_DOWN = 0x40 +JOYPAD_LEFT = 0x20 +JOYPAD_RIGHT = 0x10 +BUTTON_OPTION1 = 0x08 +BUTTON_OPTION2 = 0x04 +BUTTON_INNER = 0x02 +BUTTON_OUTER = 0x01 + SWITCHES = $FCB1 +; SWITCHES bit definitions +CART1_IO_INACTIVE = 0x04 +CART0_IO_INACTIVE = 0x02 +BUTTON_PAUSE = 0x01 + RCART0 = $FCB2 RCART1 = $FCB3 LEDS = $FCC0 @@ -133,72 +171,71 @@ PARSTATUS = $FCC2 PARDATA = $FCC3 HOWIE = $FCC4 - -; *** +; ; *** Mikey Addresses ; *** ; Mikey timers ; Logical timer names -TIMER0 = $FD00 -TIMER1 = $FD04 -TIMER2 = $FD08 -TIMER3 = $FD0C -TIMER4 = $FD10 -TIMER5 = $FD14 -TIMER6 = $FD18 -TIMER7 = $FD1C -HTIMER = TIMER0 ; horizontal line timer (timer 0) -VTIMER = TIMER2 ; vertical blank timer (timer 2) -STIMER = TIMER7 ; sound timer (timer 7) +TIMER0 = $FD00 +TIMER1 = $FD04 +TIMER2 = $FD08 +TIMER3 = $FD0C +TIMER4 = $FD10 +TIMER5 = $FD14 +TIMER6 = $FD18 +TIMER7 = $FD1C +HTIMER = TIMER0 ; horizontal line timer (timer 0) +VTIMER = TIMER2 ; vertical blank timer (timer 2) +STIMER = TIMER7 ; sound timer (timer 7) -HTIMBKUP = $FD00 ; horizontal line timer (timer 0) -HTIMCTLA = $FD01 -HTIMCNT = $FD02 -HTIMCTLB = $FD03 -VTIMBKUP = $FD08 ; vertical blank timer (timer 2) -VTIMCTLA = $FD09 -VTIMCNT = $FD0A -VTIMCTLB = $FD0B -BAUDBKUP = $FD10 ; serial timer (timer 4) -STIMBKUP = $FD1C ; sound timer (timer 7) -STIMCTLA = $FD1D -STIMCNT = $FD1E -STIMCTLB = $FD1F +HTIMBKUP = $FD00 ; horizontal line timer (timer 0) +HTIMCTLA = $FD01 +HTIMCNT = $FD02 +HTIMCTLB = $FD03 +VTIMBKUP = $FD08 ; vertical blank timer (timer 2) +VTIMCTLA = $FD09 +VTIMCNT = $FD0A +VTIMCTLB = $FD0B +BAUDBKUP = $FD10 ; serial timer (timer 4) +STIMBKUP = $FD1C ; sound timer (timer 7) +STIMCTLA = $FD1D +STIMCNT = $FD1E +STIMCTLB = $FD1F -TIM0BKUP = $FD00 -TIM0CTLA = $FD01 -TIM0CNT = $FD02 -TIM0CTLB = $FD03 -TIM1BKUP = $FD04 -TIM1CTLA = $FD05 -TIM1CNT = $FD06 -TIM1CTLB = $FD07 -TIM2BKUP = $FD08 -TIM2CTLA = $FD09 -TIM2CNT = $FD0A -TIM2CTLB = $FD0B -TIM3BKUP = $FD0C -TIM3CTLA = $FD0D -TIM3CNT = $FD0E -TIM3CTLB = $FD0F -TIM4BKUP = $FD10 -TIM4CTLA = $FD11 -TIM4CNT = $FD12 -TIM4CTLB = $FD13 -TIM5BKUP = $FD14 -TIM5CTLA = $FD15 -TIM5CNT = $FD16 -TIM5CTLB = $FD17 -TIM6BKUP = $FD18 -TIM6CTLA = $FD19 -TIM6CNT = $FD1A -TIM6CTLB = $FD1B -TIM7BKUP = $FD1C -TIM7CTLA = $FD1D -TIM7CNT = $FD1E -TIM7CTLB = $FD1F +TIM0BKUP = $FD00 +TIM0CTLA = $FD01 +TIM0CNT = $FD02 +TIM0CTLB = $FD03 +TIM1BKUP = $FD04 +TIM1CTLA = $FD05 +TIM1CNT = $FD06 +TIM1CTLB = $FD07 +TIM2BKUP = $FD08 +TIM2CTLA = $FD09 +TIM2CNT = $FD0A +TIM2CTLB = $FD0B +TIM3BKUP = $FD0C +TIM3CTLA = $FD0D +TIM3CNT = $FD0E +TIM3CTLB = $FD0F +TIM4BKUP = $FD10 +TIM4CTLA = $FD11 +TIM4CNT = $FD12 +TIM4CTLB = $FD13 +TIM5BKUP = $FD14 +TIM5CTLA = $FD15 +TIM5CNT = $FD16 +TIM5CTLB = $FD17 +TIM6BKUP = $FD18 +TIM6CTLA = $FD19 +TIM6CNT = $FD1A +TIM6CTLB = $FD1B +TIM7BKUP = $FD1C +TIM7CTLA = $FD1D +TIM7CNT = $FD1E +TIM7CTLB = $FD1F ; Timer offsets TIM_BACKUP = 0 @@ -212,7 +249,6 @@ RESET_DONE = %01000000 ENABLE_RELOAD = %00010000 ENABLE_COUNT = %00001000 AUD_CLOCK_MASK = %00000111 - ; Clock settings AUD_LINKING = %00000111 AUD_64 = %00000110 @@ -278,15 +314,16 @@ ENABLE_INTEGRATE = %00100000 ; Stereo capability does not exist in all Lynxes ; Left and right may be reversed, and if so will be corrected in a later ; release +ATTENREG0 = $FD40 ; Stereo attenuation registers +ATTENREG1 = $FD41 +ATTENREG2 = $FD42 +ATTENREG3 = $FD43 -ATTENREG0 = $FD40 ; Stereo attenuation registers -ATTENREG1 = $FD41 -ATTENREG2 = $FD42 -ATTENREG3 = $FD43 +MPAN = $FD44 +MSTEREO = $FD50 +; Bit definitions for MPAN and MSTEREO registers LEFT_ATTENMASK = %11110000 RIGHT_ATTENMASK = %00001111 - -; Bit definitions for MPAN and MSTEREO registers LEFT3_SELECT = %10000000 LEFT2_SELECT = %01000000 LEFT1_SELECT = %00100000 @@ -296,13 +333,10 @@ RIGHT2_SELECT = %00000100 RIGHT1_SELECT = %00000010 RIGHT0_SELECT = %00000001 -MPAN = $FD44 -MSTEREO = $FD50 - ; Mikey interrupts -INTRST = $FD80 -INTSET = $FD81 +INTRST = $FD80 +INTSET = $FD81 ; Interrupt bits in INTRST and INTSET TIMER0_INTERRUPT = %00000001 From 336c4287c5dc523144315cb40af07db1d9e79ffe Mon Sep 17 00:00:00 2001 From: Alex Thissen Date: Fri, 9 Aug 2024 15:17:26 +0200 Subject: [PATCH 05/11] Missed some dangles spaces --- asminc/lynx.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/asminc/lynx.inc b/asminc/lynx.inc index 458cd650f..542393847 100644 --- a/asminc/lynx.inc +++ b/asminc/lynx.inc @@ -159,7 +159,7 @@ BUTTON_INNER = 0x02 BUTTON_OUTER = 0x01 SWITCHES = $FCB1 -; SWITCHES bit definitions +; SWITCHES bit definitions CART1_IO_INACTIVE = 0x04 CART0_IO_INACTIVE = 0x02 BUTTON_PAUSE = 0x01 @@ -377,7 +377,7 @@ EXTERNAL_POWER = %00000001 SERCTL = $FD8C ; SERCTL bit definitions for write operations -TXINTEN = %10000000 +TXINTEN = %10000000 RXINTEN = %01000000 PAREN = %00010000 RESETERR = %00001000 From 489989f4c8eabf8b42cae6d6f62ab90d37f652b2 Mon Sep 17 00:00:00 2001 From: Alex Thissen Date: Fri, 9 Aug 2024 15:28:54 +0200 Subject: [PATCH 06/11] Changed 0x hex values to % binary values --- asminc/lynx.inc | 52 ++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/asminc/lynx.inc b/asminc/lynx.inc index 542393847..150bee6d1 100644 --- a/asminc/lynx.inc +++ b/asminc/lynx.inc @@ -130,39 +130,39 @@ EVER_ON = %00000100 ; everon detector enable SPRSYS = $FC92 ; SPRSYS bit definitions for write operations -SIGNMATH = 0x80 ; signed math -ACCUMULATE = 0x40 ; accumulate multiplication results -NO_COLLIDE = 0x20 ; do not collide with any sprites (also SPRCOLL bit definition) -VSTRETCH = 0x10 ; stretch v -LEFTHAND = 0x08 -CLR_UNSAFE = 0x04 ; unsafe access reset -SPRITESTOP = 0x02 ; request to stop sprite process +SIGNMATH = %10000000 ; signed math +ACCUMULATE = %01000000 ; accumulate multiplication results +NO_COLLIDE = %00100000 ; do not collide with any sprites (also SPRCOLL bit definition) +VSTRETCH = %00010000 ; stretch v +LEFTHAND = %00001000 +CLR_UNSAFE = %00000100 ; unsafe access reset +SPRITESTOP = %00000010 ; request to stop sprite process ; SPRSYS bit definitions for read operations -MATHWORKING = 0x80 ; math operation in progress -MATHWARNING = 0x40 ; accumulator overflow on multiple or divide by zero -MATHCARRY = 0x20 ; last carry bit -VSTRETCHING = 0x10 -LEFTHANDED = 0x08 -UNSAFE_ACCESS = 0x04 ; unsafe access performed -SPRITETOSTOP = 0x02 ; requested to stop -SPRITEWORKING = 0x01 ; sprite process is active +MATHWORKING = %10000000 ; math operation in progress +MATHWARNING = %01000000 ; accumulator overflow on multiple or divide by zero +MATHCARRY = %00100000 ; last carry bit +VSTRETCHING = %00010000 +LEFTHANDED = %00001000 +UNSAFE_ACCESS = %00000100 ; unsafe access performed +SPRITETOSTOP = %00000010 ; requested to stop +SPRITEWORKING = %00000001 ; sprite process is active JOYSTICK = $FCB0 ; JOYSTICK bit definitions -JOYPAD_UP = 0x80 -JOYPAD_DOWN = 0x40 -JOYPAD_LEFT = 0x20 -JOYPAD_RIGHT = 0x10 -BUTTON_OPTION1 = 0x08 -BUTTON_OPTION2 = 0x04 -BUTTON_INNER = 0x02 -BUTTON_OUTER = 0x01 +JOYPAD_UP = %10000000 +JOYPAD_DOWN = %01000000 +JOYPAD_LEFT = %00100000 +JOYPAD_RIGHT = %00010000 +BUTTON_OPTION1 = %00001000 +BUTTON_OPTION2 = %00000100 +BUTTON_INNER = %00000010 +BUTTON_OUTER = %00000001 SWITCHES = $FCB1 ; SWITCHES bit definitions -CART1_IO_INACTIVE = 0x04 -CART0_IO_INACTIVE = 0x02 -BUTTON_PAUSE = 0x01 +CART1_IO_INACTIVE = %00000100 +CART0_IO_INACTIVE = %00000010 +BUTTON_PAUSE = %00000001 RCART0 = $FCB2 RCART1 = $FCB3 From 1f1a004a050fe74e030fcf3b9dfe34faad4c9645 Mon Sep 17 00:00:00 2001 From: Alex Thissen Date: Fri, 9 Aug 2024 15:54:05 +0200 Subject: [PATCH 07/11] Minor tweaks to Suzy struct types. Named math union --- include/_suzy.h | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/include/_suzy.h b/include/_suzy.h index 29a263880..41029a071 100644 --- a/include/_suzy.h +++ b/include/_suzy.h @@ -258,28 +258,28 @@ struct _math_divide { /* Suzy Hardware Registers */ struct __suzy { - unsigned char *tmpadr; // 0xFC00 Temporary address - unsigned int tiltacc; // 0xFC02 Tilt accumulator - unsigned int hoff; // 0xFC04 Offset to H edge of screen - unsigned int voff; // 0xFC06 Offset to V edge of screen + unsigned char *tmpadr; // 0xFC00 Temporary address + unsigned int tiltacc; // 0xFC02 Tilt accumulator + unsigned int hoff; // 0xFC04 Offset to H edge of screen + unsigned int voff; // 0xFC06 Offset to V edge of screen unsigned char *sprbase; // 0xFC08 Base address of sprite unsigned char *colbase; // 0xFC0A Base address of collision buffer unsigned char *vidadr; // 0xFC0C Current vid buffer address unsigned char *coladr; // 0xFC0E Current col buffer address unsigned char *scbnext; // 0xFC10 Address of next SCB unsigned char *sprdline; // 0xFC12 start of sprite data line address - unsigned char *hposstrt; // 0xFC14 start hpos - unsigned char *vposstrt; // 0xFC16 start vpos - unsigned char *sprhsize; // 0xFC18 sprite h size - unsigned char *sprvsize; // 0xFC1A sprite v size - unsigned int stretchl; // 0xFC1C H size adder - unsigned int tilt; // 0xFC1E H pos adder - unsigned int sprdoff; // 0xFC20 offset to next sprite data line - unsigned int sprvpos; // 0xFC22 current vpos - unsigned int colloff; // 0xFC24 offset to collision depository - unsigned int vsizeacc; // 0xFC26 vertical size accumulator - unsigned int hsizeoff; // 0xFC28 horizontal size offset - unsigned int vsizeoff; // 0xFC2A vertical size offset + unsigned int hposstrt; // 0xFC14 start hpos + unsigned int vposstrt; // 0xFC16 start vpos + unsigned int sprhsize; // 0xFC18 sprite h size + unsigned int sprvsize; // 0xFC1A sprite v size + unsigned int stretchl; // 0xFC1C H size adder + unsigned int tilt; // 0xFC1E H pos adder + unsigned int sprdoff; // 0xFC20 offset to next sprite data line + unsigned int sprvpos; // 0xFC22 current vpos + unsigned int colloff; // 0xFC24 offset to collision depository + unsigned int vsizeacc; // 0xFC26 vertical size accumulator + unsigned int hsizeoff; // 0xFC28 horizontal size offset + unsigned int vsizeoff; // 0xFC2A vertical size offset unsigned char *scbaddr; // 0xFC2C address of current SCB unsigned char *procaddr; // 0xFC2E address of current spr data proc unsigned char unused0[32]; // 0xFC30 - 0xFC4F reserved/unused @@ -306,7 +306,7 @@ struct __suzy { struct _math_unsigned_multiply unsigned_multiply; struct _math_signed_multiply signed_multiply; struct _math_divide divide; - }; + } math; unsigned char unused4[16]; // 0xFC70 - 0xFC7F do not use unsigned char sprctl0; // 0xFC80 sprite control bits 0 unsigned char sprctl1; // 0xFC81 sprite control bits 1 From 0c018919fea8d0fc742311c0e37845a38df0f2df Mon Sep 17 00:00:00 2001 From: Alex Thissen Date: Mon, 28 Oct 2024 14:20:09 +0100 Subject: [PATCH 08/11] Removed union and structures for Suzy math --- include/_suzy.h | 76 +++++++++++++------------------------------------ 1 file changed, 20 insertions(+), 56 deletions(-) diff --git a/include/_suzy.h b/include/_suzy.h index 41029a071..5f4909012 100644 --- a/include/_suzy.h +++ b/include/_suzy.h @@ -227,36 +227,7 @@ enum { SPRITEWORKING = 0x01 // sprite process is active }; -// Structures for math registers -struct _math_unsigned_multiply { - unsigned int factor1; // 0xFC52 - 0xFC53 - unsigned int factor2; // 0xFC54 - 0xFC55 write starts multiply - unsigned char unused2[10]; // 0xFC56 - 0xFC5F do not use - unsigned long product; // 0xFC60 - 0xFC63 - unsigned char unused3[8]; // 0xFC64 - 0xFC6B do not use - unsigned long accumulate; // 0xFC6C - 0xFC6F -}; - -struct _math_signed_multiply { - int factor1; // 0xFC52 - 0xFC53 - int factor2; // 0xFC54 - 0xFC55 write starts multiply - unsigned char unused2[10]; // 0xFC56 - 0xFC5F do not use - long product; // 0xFC60 - 0xFC63 - unsigned char unused3[8]; // 0xFC64 - 0xFC6B do not use - long accumulate; // 0xFC6C - 0xFC6F -}; - -struct _math_divide { - unsigned long quotient; // 0xFC52 - 0xFC55 - unsigned int divisor; // 0xFC56 - 0xFC57 - unsigned char unused2[8]; // 0xFC58 - 0xFC5F do not use - unsigned int dividend2; // 0xFC60 - 0xFC61 - unsigned int dividend1; // 0xFC62 - 0xFC63 write starts divide - unsigned char unused3[8]; // 0xFC64 - 0xFC6B do not use - unsigned long remainder; // 0xFC6C - 0xFC6F -}; - -/* Suzy Hardware Registers */ +// Suzy hardware registers struct __suzy { unsigned char *tmpadr; // 0xFC00 Temporary address unsigned int tiltacc; // 0xFC02 Tilt accumulator @@ -284,29 +255,22 @@ struct __suzy { unsigned char *procaddr; // 0xFC2E address of current spr data proc unsigned char unused0[32]; // 0xFC30 - 0xFC4F reserved/unused unsigned char unused1[2]; // 0xFC50 - 0xFC51 do not use - union { - struct { - unsigned char mathd; // 0xFC52 - unsigned char mathc; // 0xFC53 - unsigned char mathb; // 0xFC54 - unsigned char matha; // 0xFC55 write starts a multiply operation - unsigned char mathp; // 0xFC56 - unsigned char mathn; // 0xFC57 - unsigned char unused2[8]; // 0xFC58 - 0xFC5F do not use - unsigned char mathh; // 0xFC60 - unsigned char mathg; // 0xFC61 - unsigned char mathf; // 0xFC62 - unsigned char mathe; // 0xFC63 write starts a divide operation - unsigned char unused3[8]; // 0xFC64 - 0xFC6B do not use - unsigned char mathm; // 0xFC6C - unsigned char mathl; // 0xFC6D - unsigned char mathk; // 0xFC6E - unsigned char mathj; // 0xFC6F - }; - struct _math_unsigned_multiply unsigned_multiply; - struct _math_signed_multiply signed_multiply; - struct _math_divide divide; - } math; + unsigned char mathd; // 0xFC52 + unsigned char mathc; // 0xFC53 + unsigned char mathb; // 0xFC54 + unsigned char matha; // 0xFC55 write starts a multiply operation + unsigned char mathp; // 0xFC56 + unsigned char mathn; // 0xFC57 + unsigned char unused2[8]; // 0xFC58 - 0xFC5F do not use + unsigned char mathh; // 0xFC60 + unsigned char mathg; // 0xFC61 + unsigned char mathf; // 0xFC62 + unsigned char mathe; // 0xFC63 write starts a divide operation + unsigned char unused3[8]; // 0xFC64 - 0xFC6B do not use + unsigned char mathm; // 0xFC6C + unsigned char mathl; // 0xFC6D + unsigned char mathk; // 0xFC6E + unsigned char mathj; // 0xFC6F unsigned char unused4[16]; // 0xFC70 - 0xFC7F do not use unsigned char sprctl0; // 0xFC80 sprite control bits 0 unsigned char sprctl1; // 0xFC81 sprite control bits 1 @@ -333,9 +297,7 @@ struct __suzy { // 0xFCC5 - 0xFCFF unused }; -// Deprecated definitions - -/* Hardware Math */ +// Hardware math registers #define FACTOR_A *(unsigned int *) 0xFC54 #define FACTOR_B *(unsigned int *) 0xFC52 #define PRODUCT0 *(unsigned int *) 0xFC60 @@ -353,6 +315,8 @@ struct __suzy { #define REMAINDER1 *(unsigned int *) 0xFC6E #define REMAINDER *(long *) 0xFC6C +// Deprecated definitions + /* MAPCTL $FFF9 */ #define HIGHSPEED 0x80 #define VECTORSPACE 0x08 From 3dad6c76fad020c2ffa21be9619bfa8119c3df0f Mon Sep 17 00:00:00 2001 From: Alex Thissen Date: Sat, 9 Nov 2024 12:01:22 +0100 Subject: [PATCH 09/11] Changed to C style comments --- include/_mikey.h | 30 +++++++++++++++--------------- include/_suzy.h | 47 ++++++++++++++++++++++++++++------------------- include/lynx.h | 10 +++++----- 3 files changed, 48 insertions(+), 39 deletions(-) diff --git a/include/_mikey.h b/include/_mikey.h index 9a50745b2..05212aac9 100644 --- a/include/_mikey.h +++ b/include/_mikey.h @@ -109,7 +109,7 @@ struct __mikey { } vectors; }; -// TIM_CONTROLA control bit definitions +/* TIM_CONTROLA control bit definitions */ enum { ENABLE_INT = 0x80, RESET_DONE = 0x40, @@ -117,13 +117,13 @@ enum { ENABLE_COUNT = 0x08 }; -// AUD_CONTROL control bit definitions +/* AUD_CONTROL control bit definitions */ enum { FEEDBACK_7 = 0x80, ENABLE_INTEGRATE = 0x20 }; -// Audio and timer clock settings for source period +/* Audio and timer clock settings for source period */ enum { AUD_LINKING = 0x07, AUD_64 = 0x06, @@ -135,7 +135,7 @@ enum { AUD_1 = 0x00 }; -// TIM_CONTROLB control bit definitions +/* TIM_CONTROLB control bit definitions */ enum { TIMER_DONE = 0x08, LAST_CLOCK = 0x04, @@ -143,7 +143,7 @@ enum { BORROW_OUT = 0x01 }; -// MPAN and MSTEREO registers bit definitions +/* MPAN and MSTEREO registers bit definitions */ enum { LEFT3_SELECT = 0x80, LEFT2_SELECT = 0x40, @@ -157,7 +157,7 @@ enum { RIGHT_ATTENMASK = 0x0F }; -// Interrupt Reset and Set bit definitions +/* Interrupt Reset and Set bit definitions */ enum { TIMER7_INT = 0x80, TIMER6_INT = 0x40, @@ -172,13 +172,13 @@ enum { HORIZONTAL_INT = TIMER0_INT }; -// SYSCTL1 bit definitions +/* SYSCTL1 bit definitions */ enum { POWERON = 0x02, CART_ADDR_STROBE = 0x01 }; -// IODIR and IODAT bit definitions +/* IODIR and IODAT bit definitions */ enum { AUDIN_BIT = 0x10, // different from AUDIN address READ_ENABLE = 0x10, // same bit for AUDIN_BIT @@ -189,7 +189,7 @@ enum { EXTERNAL_POWER = 0x01 }; -// SERCTL bit definitions for write operations +/* SERCTL bit definitions for write operations */ enum { TXINTEN = 0x80, RXINTEN = 0x40, @@ -200,7 +200,7 @@ enum { PAREVEN = 0x01 }; -// SERCTL bit definitions for read operations +/* SERCTL bit definitions for read operations */ enum { TXRDY = 0x80, RXRDY = 0x40, @@ -212,7 +212,7 @@ enum { PARBIT = 0x01 }; -// DISPCTL bit definitions +/* DISPCTL bit definitions */ enum { DISP_COLOR = 0x08, // must be set to 1 DISP_FOURBIT = 0x04, // must be set to 1 @@ -220,7 +220,7 @@ enum { DMA_ENABLE = 0x01 // must be set to 1 }; -// MTEST0 bit definitions +/* MTEST0 bit definitions */ enum { AT_CNT16 = 0x80, AT_TEST = 0x40, @@ -232,7 +232,7 @@ enum { CPU_TEST = 0x01 }; -// MTEST1 bit definitions +/* MTEST1 bit definitions */ enum { P_CNT16 = 0x40, REF_CNT16 = 0x20, @@ -243,7 +243,7 @@ enum { REF_DIS = 0x01 }; -// MTEST2 bit definitions +/* MTEST2 bit definitions */ enum { V_STROBE = 0x10, V_ZERO = 0x08, @@ -252,7 +252,7 @@ enum { V_BLANKEF = 0x01 }; -// MAPCTL bit definitions +/* MAPCTL bit definitions */ enum { TURBO_DISABLE = 0x80, VECTOR_SPACE = 0x08, diff --git a/include/_suzy.h b/include/_suzy.h index 5f4909012..a9d5ddd7b 100644 --- a/include/_suzy.h +++ b/include/_suzy.h @@ -27,7 +27,7 @@ #ifndef __SUZY_H #define __SUZY_H -// JOYSTICK bit definitions +/* JOYSTICK bit definitions */ enum { JOYPAD_RIGHT = 0x10, JOYPAD_LEFT = 0x20, @@ -39,14 +39,14 @@ enum { BUTTON_OUTER = 0x01 }; -// SWITCHES bit definitions +/* SWITCHES bit definitions */ enum { CART1_IO_INACTIVE = 0x04, CART0_IO_INACTIVE = 0x02, BUTTON_PAUSE = 0x01 }; -// SPRCTL0 bit definitions +/* SPRCTL0 bit definitions */ enum { BPP_4 = 0xC0, BPP_3 = 0x80, @@ -64,7 +64,7 @@ enum { TYPE_BACKGROUND = 0x00 }; -// SPRCTL1 bit definitions +/* SPRCTL1 bit definitions */ enum { LITERAL = 0x80, PACKED = 0x00, @@ -79,9 +79,10 @@ enum { DRAWLEFT = 0x01 }; -// Sprite control block (SCB) definitions +/* Sprite control block (SCB) definitions */ -typedef struct SCB_REHVST_PAL { // SCB with all attributes +/* SCB with all attributes */ +typedef struct SCB_REHVST_PAL { unsigned char sprctl0; unsigned char sprctl1; unsigned char sprcoll; @@ -96,7 +97,8 @@ typedef struct SCB_REHVST_PAL { // SCB with all attributes unsigned char penpal[8]; } SCB_REHVST_PAL; -typedef struct SCB_REHVST { // SCB without pallette +/* SCB without pallette */ +typedef struct SCB_REHVST { unsigned char sprctl0; unsigned char sprctl1; unsigned char sprcoll; @@ -110,7 +112,8 @@ typedef struct SCB_REHVST { // SCB without pallette unsigned int tilt; } SCB_REHVST; -typedef struct SCB_REHV { // SCB without stretch/tilt +/* SCB without stretch/tilt */ +typedef struct SCB_REHV { unsigned char sprctl0; unsigned char sprctl1; unsigned char sprcoll; @@ -122,7 +125,8 @@ typedef struct SCB_REHV { // SCB without stretch/tilt unsigned int vsize; } SCB_REHV; -typedef struct SCB_REHV_PAL { // SCB without str/tilt, w/ penpal +/* SCB without stretch/tilt, with penpal */ +typedef struct SCB_REHV_PAL { unsigned char sprctl0; unsigned char sprctl1; unsigned char sprcoll; @@ -135,7 +139,8 @@ typedef struct SCB_REHV_PAL { // SCB without str/tilt, w/ penpal unsigned char penpal[8]; } SCB_REHV_PAL; -typedef struct SCB_REHVS { // SCB w/o tilt & penpal +/* SCB without tilt/penpal */ +typedef struct SCB_REHVS { unsigned char sprctl0; unsigned char sprctl1; unsigned char sprcoll; @@ -148,7 +153,8 @@ typedef struct SCB_REHVS { // SCB w/o tilt & penpal unsigned int stretch; } SCB_REHVS; -typedef struct SCB_REHVS_PAL { // SCB w/o tilt w/penpal +/* SCB without tilt, with penpal */ +typedef struct SCB_REHVS_PAL { unsigned char sprctl0; unsigned char sprctl1; unsigned char sprcoll; @@ -162,7 +168,8 @@ typedef struct SCB_REHVS_PAL { // SCB w/o tilt w/penpal unsigned char penpal[8]; } SCB_REHVS_PAL; -typedef struct SCB_RENONE { // SCB w/o size/stretch/tilt/pal +/* SCB without size/stretch/tilt/penpal */ +typedef struct SCB_RENONE { unsigned char sprctl0; unsigned char sprctl1; unsigned char sprcoll; @@ -172,7 +179,8 @@ typedef struct SCB_RENONE { // SCB w/o size/stretch/tilt/pal signed int vpos; } SCB_RENONE; -typedef struct SCB_RENONE_PAL { // SCB w/o size/str/tilt w/penpal +/* SCB without size/str/tilt, with penpal */ +typedef struct SCB_RENONE_PAL { unsigned char sprctl0; unsigned char sprctl1; unsigned char sprcoll; @@ -199,13 +207,13 @@ typedef struct PENPAL_1 { unsigned char penpal[1]; } PENPAL_1; -// SPRGO bit definitions +/* SPRGO bit definitions */ enum { SPRITE_GO = 0x01, // sprite process start bit EVER_ON = 0x04 // everon detector enable }; -// SPRSYS bit definitions for write operations +/* SPRSYS bit definitions for write operations */ enum { SIGNMATH = 0x80, // signed math ACCUMULATE = 0x40, // accumulate multiplication results @@ -215,7 +223,8 @@ enum { CLR_UNSAFE = 0x04, // unsafe access reset SPRITESTOP = 0x02 // request to stop sprite process }; -// SPRSYS bit definitions for read operations + +/* SPRSYS bit definitions for read operations */ enum { MATHWORKING = 0x80, // math operation in progress MATHWARNING = 0x40, // accumulator overflow on multiple or divide by zero @@ -227,7 +236,7 @@ enum { SPRITEWORKING = 0x01 // sprite process is active }; -// Suzy hardware registers +/* Suzy hardware registers */ struct __suzy { unsigned char *tmpadr; // 0xFC00 Temporary address unsigned int tiltacc; // 0xFC02 Tilt accumulator @@ -297,7 +306,7 @@ struct __suzy { // 0xFCC5 - 0xFCFF unused }; -// Hardware math registers +/* Hardware math registers */ #define FACTOR_A *(unsigned int *) 0xFC54 #define FACTOR_B *(unsigned int *) 0xFC52 #define PRODUCT0 *(unsigned int *) 0xFC60 @@ -315,7 +324,7 @@ struct __suzy { #define REMAINDER1 *(unsigned int *) 0xFC6E #define REMAINDER *(long *) 0xFC6C -// Deprecated definitions +/* Deprecated definitions */ /* MAPCTL $FFF9 */ #define HIGHSPEED 0x80 diff --git a/include/lynx.h b/include/lynx.h index e2c0c503f..fe4006461 100644 --- a/include/lynx.h +++ b/include/lynx.h @@ -79,12 +79,12 @@ /* No support for dynamically loadable drivers */ #define DYN_DRV 0 -// Addresses of static drivers +/* Addresses of static drivers */ extern void lynx_stdjoy_joy[]; // Referred to by joy_static_stddrv[] extern void lynx_comlynx_ser[]; // Referred to by ser_static_stddrv[] extern void lynx_160_102_16_tgi[]; // Referred to by tgi_static_stddrv[] -// Sound support +/* Sound support */ void lynx_snd_init (void); // Initialize the sound driver void lynx_snd_pause (void); // Pause sound void lynx_snd_continue (void); // Continue sound after pause @@ -93,18 +93,18 @@ void lynx_snd_stop (void); // Stop sound on all channels void __fastcall__ lynx_snd_stop_channel (unsigned char channel); // Stop sound on all channels unsigned char lynx_snd_active(void); // Show which channels are active -// Cartridge access +/* Cartridge access */ void __fastcall__ lynx_load (int file_number); // Load a file into RAM using a zero-based index void __fastcall__ lynx_exec (int file_number); // Load a file into ram and execute it -// EEPROM access +/* EEPROM access */ unsigned __fastcall__ lynx_eeprom_read (unsigned char cell); // Read a 16 bit word from the given address unsigned __fastcall__ lynx_eeprom_write (unsigned char cell, unsigned val); // Write the word at the given address void __fastcall__ lynx_eeprom_erase (unsigned char cell); // Clear the word at the given address unsigned __fastcall__ lynx_eeread (unsigned cell); // Read a 16 bit word from the given address 93C46, 93C66 or 93C86 unsigned __fastcall__ lynx_eewrite (unsigned cell, unsigned val); // Write the word at the given address 93C46, 93C66 or 93C86 -// TGI extras +/* TGI extras */ #define tgi_sprite(spr) tgi_ioctl(0, spr) #define tgi_flip() tgi_ioctl(1, (void*)0) #define tgi_setbgcolor(bgcol) tgi_ioctl(2, (void*)(bgcol)) From 40369124636a150a841024f6cf2e44b49a082416 Mon Sep 17 00:00:00 2001 From: Alex Thissen Date: Sat, 9 Nov 2024 12:06:37 +0100 Subject: [PATCH 10/11] Fix to trailing whitespace --- include/_suzy.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/_suzy.h b/include/_suzy.h index a9d5ddd7b..5de8ad678 100644 --- a/include/_suzy.h +++ b/include/_suzy.h @@ -113,7 +113,7 @@ typedef struct SCB_REHVST { } SCB_REHVST; /* SCB without stretch/tilt */ -typedef struct SCB_REHV { +typedef struct SCB_REHV { unsigned char sprctl0; unsigned char sprctl1; unsigned char sprcoll; @@ -180,7 +180,7 @@ typedef struct SCB_RENONE { } SCB_RENONE; /* SCB without size/str/tilt, with penpal */ -typedef struct SCB_RENONE_PAL { +typedef struct SCB_RENONE_PAL { unsigned char sprctl0; unsigned char sprctl1; unsigned char sprcoll; From a945bedefc424f44d205f697ba413fd853854e3d Mon Sep 17 00:00:00 2001 From: Alex Thissen Date: Sat, 9 Nov 2024 19:46:11 +0100 Subject: [PATCH 11/11] Replaced all C++ style comments from Lynx include files --- include/_mikey.h | 123 ++++++++++++++++++------------------ include/_suzy.h | 160 +++++++++++++++++++++++------------------------ include/lynx.h | 44 ++++++------- 3 files changed, 163 insertions(+), 164 deletions(-) diff --git a/include/_mikey.h b/include/_mikey.h index 05212aac9..6e16e98ca 100644 --- a/include/_mikey.h +++ b/include/_mikey.h @@ -53,59 +53,59 @@ typedef struct _mikey_audio { /* Define a structure with the mikey register offsets */ struct __mikey { - struct _mikey_timer timer0; // 0xFD00 - struct _mikey_timer timer1; // 0xFD04 - struct _mikey_timer timer2; // 0xFD08 - struct _mikey_timer timer3; // 0xFD0C - struct _mikey_timer timer4; // 0xFD10 - struct _mikey_timer timer5; // 0xFD14 - struct _mikey_timer timer6; // 0xFD18 - struct _mikey_timer timer7; // 0xFD1C - struct _mikey_audio channel_a; // 0xFD20 - struct _mikey_audio channel_b; // 0xFD28 - struct _mikey_audio channel_c; // 0xFD30 - struct _mikey_audio channel_d; // 0xFD38 - unsigned char attena; // 0xFD40 ?? not yet allocated? - unsigned char attenb; // 0xFD41 | - unsigned char attenc; // 0xFD42 | - unsigned char attend; // 0xFD43 | - unsigned char panning; // 0xFD44 | - unsigned char unused0[11]; // 0xFD45 - 0xFD4F not used - unsigned char mstereo; // 0xFD50 stereo control bits - unsigned char unused1[47]; // 0xFD51 - 0xFD7F not used - unsigned char intrst; // 0xFD80 interrupt poll 0 - unsigned char intset; // 0xFD81 interrupt poll 1 - unsigned char unused2[2]; // 0xFD82 - 0xFD83 not used - unsigned char magrdy0; // 0xFD84 mag tape channel0 ready bit - unsigned char magrdy1; // 0xFD85 mag tape channel1 ready bit - unsigned char audin; // 0xFD86 audio in - unsigned char sysctl1; // 0xFD87 control bits - unsigned char mikeyrev; // 0xFD88 mikey hardware rev - unsigned char mikeysrev; // 0xFD89 mikey software rev - unsigned char iodir; // 0xFD8A parallel i/o data dir - unsigned char iodat; // 0xFD8B parallel data - unsigned char serctl; // 0xFD8C serial control register - unsigned char serdat; // 0xFD8D serial data - unsigned char unused3[2]; // 0xFD8E - 0xFD8F not used - unsigned char sdoneack; // 0xFD90 suzy done acknowledge - unsigned char cpusleep; // 0xFD91 cpu bus request disable - unsigned char dispctl; // 0xFD92 video bus request enable, viddma - unsigned char pkbkup; // 0xFD93 magic 'P' count - unsigned char *scrbase; // 0xFD94 start address of video display - unsigned char unused4[6]; // 0xFD96 - 0xFD9B not used - unsigned char mtest0; // 0xFD9C - unsigned char mtest1; // 0xFD9D - unsigned char mtest2; // 0xFD9E - unsigned char unused5; // 0xFD9F not used - unsigned char palette[32]; // 0xFDA0 - 0xFDBF palette 32 bytes - unsigned char unused6[64]; // 0xFDC0 - 0xFDFF not used - unsigned char bootrom[504]; // 0xFE00 - 0xFFD8 boot rom - unsigned char reserved; // 0xFFD8 reserved for future hardware - unsigned char mapctl; // 0xFFF9 map control register + struct _mikey_timer timer0; /* 0xFD00 */ + struct _mikey_timer timer1; /* 0xFD04 */ + struct _mikey_timer timer2; /* 0xFD08 */ + struct _mikey_timer timer3; /* 0xFD0C */ + struct _mikey_timer timer4; /* 0xFD10 */ + struct _mikey_timer timer5; /* 0xFD14 */ + struct _mikey_timer timer6; /* 0xFD18 */ + struct _mikey_timer timer7; /* 0xFD1C */ + struct _mikey_audio channel_a; /* 0xFD20 */ + struct _mikey_audio channel_b; /* 0xFD28 */ + struct _mikey_audio channel_c; /* 0xFD30 */ + struct _mikey_audio channel_d; /* 0xFD38 */ + unsigned char attena; /* 0xFD40 ?? not yet allocated? */ + unsigned char attenb; /* 0xFD41 | */ + unsigned char attenc; /* 0xFD42 | */ + unsigned char attend; /* 0xFD43 | */ + unsigned char panning; /* 0xFD44 | */ + unsigned char unused0[11]; /* 0xFD45 - 0xFD4F not used */ + unsigned char mstereo; /* 0xFD50 stereo control bits */ + unsigned char unused1[47]; /* 0xFD51 - 0xFD7F not used */ + unsigned char intrst; /* 0xFD80 interrupt poll 0 */ + unsigned char intset; /* 0xFD81 interrupt poll 1 */ + unsigned char unused2[2]; /* 0xFD82 - 0xFD83 not used */ + unsigned char magrdy0; /* 0xFD84 mag tape channel0 ready bit */ + unsigned char magrdy1; /* 0xFD85 mag tape channel1 ready bit */ + unsigned char audin; /* 0xFD86 audio in */ + unsigned char sysctl1; /* 0xFD87 control bits */ + unsigned char mikeyrev; /* 0xFD88 mikey hardware rev */ + unsigned char mikeysrev; /* 0xFD89 mikey software rev */ + unsigned char iodir; /* 0xFD8A parallel i/o data dir */ + unsigned char iodat; /* 0xFD8B parallel data */ + unsigned char serctl; /* 0xFD8C serial control register */ + unsigned char serdat; /* 0xFD8D serial data */ + unsigned char unused3[2]; /* 0xFD8E - 0xFD8F not used */ + unsigned char sdoneack; /* 0xFD90 suzy done acknowledge */ + unsigned char cpusleep; /* 0xFD91 cpu bus request disable */ + unsigned char dispctl; /* 0xFD92 video bus request enable, viddma */ + unsigned char pkbkup; /* 0xFD93 magic 'P' count */ + unsigned char *scrbase; /* 0xFD94 start address of video display */ + unsigned char unused4[6]; /* 0xFD96 - 0xFD9B not used */ + unsigned char mtest0; /* 0xFD9C */ + unsigned char mtest1; /* 0xFD9D */ + unsigned char mtest2; /* 0xFD9E */ + unsigned char unused5; /* 0xFD9F not used */ + unsigned char palette[32]; /* 0xFDA0 - 0xFDBF palette 32 bytes */ + unsigned char unused6[64]; /* 0xFDC0 - 0xFDFF not used */ + unsigned char bootrom[504]; /* 0xFE00 - 0xFFD8 boot rom */ + unsigned char reserved; /* 0xFFD8 reserved for future hardware */ + unsigned char mapctl; /* 0xFFF9 map control register */ struct { - unsigned char *nmi; // 0xFFFA NMI vector - unsigned char *reset; // 0xFFFB reset vector - unsigned char *irq; // 0xFFFC IRQ vector + unsigned char *nmi; /* 0xFFFA NMI vector */ + unsigned char *reset; /* 0xFFFB reset vector */ + unsigned char *irq; /* 0xFFFC IRQ vector */ } vectors; }; @@ -180,12 +180,12 @@ enum { /* IODIR and IODAT bit definitions */ enum { - AUDIN_BIT = 0x10, // different from AUDIN address - READ_ENABLE = 0x10, // same bit for AUDIN_BIT + AUDIN_BIT = 0x10, /* different from AUDIN address */ + READ_ENABLE = 0x10, /* same bit for AUDIN_BIT */ RESTLESS = 0x08, - NOEXP = 0x04, // if set, redeye is not connected - CART_ADDR_DATA = 0x02, // - CART_POWER_OFF = 0x02, // same bit for CART_ADDR_DATA + NOEXP = 0x04, /* if set, redeye is not connected */ + CART_ADDR_DATA = 0x02, + CART_POWER_OFF = 0x02, /* same bit for CART_ADDR_DATA */ EXTERNAL_POWER = 0x01 }; @@ -214,10 +214,10 @@ enum { /* DISPCTL bit definitions */ enum { - DISP_COLOR = 0x08, // must be set to 1 - DISP_FOURBIT = 0x04, // must be set to 1 - DISP_FLIP = 0x02, // - DMA_ENABLE = 0x01 // must be set to 1 + DISP_COLOR = 0x08, /* must be set to 1 */ + DISP_FOURBIT = 0x04, /* must be set to 1 */ + DISP_FLIP = 0x02, + DMA_ENABLE = 0x01 /* must be set to 1 */ }; /* MTEST0 bit definitions */ @@ -262,4 +262,3 @@ enum { }; #endif - diff --git a/include/_suzy.h b/include/_suzy.h index 5de8ad678..50845c958 100644 --- a/include/_suzy.h +++ b/include/_suzy.h @@ -209,101 +209,101 @@ typedef struct PENPAL_1 { /* SPRGO bit definitions */ enum { - SPRITE_GO = 0x01, // sprite process start bit - EVER_ON = 0x04 // everon detector enable + SPRITE_GO = 0x01, /* sprite process start bit */ + EVER_ON = 0x04 /* everon detector enable */ }; /* SPRSYS bit definitions for write operations */ enum { - SIGNMATH = 0x80, // signed math - ACCUMULATE = 0x40, // accumulate multiplication results - NO_COLLIDE = 0x20, // do not collide with any sprites (also SPRCOLL bit definition) - VSTRETCH = 0x10, // stretch v + SIGNMATH = 0x80, /* signed math */ + ACCUMULATE = 0x40, /* accumulate multiplication results */ + NO_COLLIDE = 0x20, /* do not collide with any sprites (also SPRCOLL bit definition) */ + VSTRETCH = 0x10, /* stretch v */ LEFTHAND = 0x08, - CLR_UNSAFE = 0x04, // unsafe access reset - SPRITESTOP = 0x02 // request to stop sprite process + CLR_UNSAFE = 0x04, /* unsafe access reset */ + SPRITESTOP = 0x02 /* request to stop sprite process */ }; /* SPRSYS bit definitions for read operations */ enum { - MATHWORKING = 0x80, // math operation in progress - MATHWARNING = 0x40, // accumulator overflow on multiple or divide by zero - MATHCARRY = 0x20, // last carry bit + MATHWORKING = 0x80, /* math operation in progress */ + MATHWARNING = 0x40, /* accumulator overflow on multiple or divide by zero */ + MATHCARRY = 0x20, /* last carry bit */ VSTRETCHING = 0x10, LEFTHANDED = 0x08, - UNSAFE_ACCESS = 0x04, // unsafe access performed - SPRITETOSTOP = 0x02, // requested to stop - SPRITEWORKING = 0x01 // sprite process is active + UNSAFE_ACCESS = 0x04, /* unsafe access performed */ + SPRITETOSTOP = 0x02, /* requested to stop */ + SPRITEWORKING = 0x01 /* sprite process is active */ }; /* Suzy hardware registers */ struct __suzy { - unsigned char *tmpadr; // 0xFC00 Temporary address - unsigned int tiltacc; // 0xFC02 Tilt accumulator - unsigned int hoff; // 0xFC04 Offset to H edge of screen - unsigned int voff; // 0xFC06 Offset to V edge of screen - unsigned char *sprbase; // 0xFC08 Base address of sprite - unsigned char *colbase; // 0xFC0A Base address of collision buffer - unsigned char *vidadr; // 0xFC0C Current vid buffer address - unsigned char *coladr; // 0xFC0E Current col buffer address - unsigned char *scbnext; // 0xFC10 Address of next SCB - unsigned char *sprdline; // 0xFC12 start of sprite data line address - unsigned int hposstrt; // 0xFC14 start hpos - unsigned int vposstrt; // 0xFC16 start vpos - unsigned int sprhsize; // 0xFC18 sprite h size - unsigned int sprvsize; // 0xFC1A sprite v size - unsigned int stretchl; // 0xFC1C H size adder - unsigned int tilt; // 0xFC1E H pos adder - unsigned int sprdoff; // 0xFC20 offset to next sprite data line - unsigned int sprvpos; // 0xFC22 current vpos - unsigned int colloff; // 0xFC24 offset to collision depository - unsigned int vsizeacc; // 0xFC26 vertical size accumulator - unsigned int hsizeoff; // 0xFC28 horizontal size offset - unsigned int vsizeoff; // 0xFC2A vertical size offset - unsigned char *scbaddr; // 0xFC2C address of current SCB - unsigned char *procaddr; // 0xFC2E address of current spr data proc - unsigned char unused0[32]; // 0xFC30 - 0xFC4F reserved/unused - unsigned char unused1[2]; // 0xFC50 - 0xFC51 do not use - unsigned char mathd; // 0xFC52 - unsigned char mathc; // 0xFC53 - unsigned char mathb; // 0xFC54 - unsigned char matha; // 0xFC55 write starts a multiply operation - unsigned char mathp; // 0xFC56 - unsigned char mathn; // 0xFC57 - unsigned char unused2[8]; // 0xFC58 - 0xFC5F do not use - unsigned char mathh; // 0xFC60 - unsigned char mathg; // 0xFC61 - unsigned char mathf; // 0xFC62 - unsigned char mathe; // 0xFC63 write starts a divide operation - unsigned char unused3[8]; // 0xFC64 - 0xFC6B do not use - unsigned char mathm; // 0xFC6C - unsigned char mathl; // 0xFC6D - unsigned char mathk; // 0xFC6E - unsigned char mathj; // 0xFC6F - unsigned char unused4[16]; // 0xFC70 - 0xFC7F do not use - unsigned char sprctl0; // 0xFC80 sprite control bits 0 - unsigned char sprctl1; // 0xFC81 sprite control bits 1 - unsigned char sprcoll; // 0xFC82 sprite collision number - unsigned char sprinit; // 0xFC83 sprite initialization bits - unsigned char unused5[4]; // 0xFC84 - 0xFC87 unused - unsigned char suzyhrev; // 0xFC88 suzy hardware rev - unsigned char suzysrev; // 0xFC89 suzy software rev - unsigned char unused6[6]; // 0xFC8A - 0xFC8F unused - unsigned char suzybusen; // 0xFC90 suzy bus enable - unsigned char sprgo; // 0xFC91 sprite process start bit - unsigned char sprsys; // 0xFC92 sprite system control bits - unsigned char unused7[29]; // 0xFC93 - 0xFCAF unused - unsigned char joystick; // 0xFCB0 joystick and buttons - unsigned char switches; // 0xFCB1 other switches - unsigned char cart0; // 0xFCB2 cart0 r/w - unsigned char cart1; // 0xFCB3 cart1 r/w - unsigned char unused8[8]; // 0xFCB4 - 0xFCBF unused - unsigned char leds; // 0xFCC0 leds - unsigned char unused9; // 0xFCC1 unused - unsigned char parstat; // 0xFCC2 parallel port status - unsigned char pardata; // 0xFCC3 parallel port data - unsigned char howie; // 0xFCC4 howie (?) - // 0xFCC5 - 0xFCFF unused + unsigned char *tmpadr; /* 0xFC00 Temporary address */ + unsigned int tiltacc; /* 0xFC02 Tilt accumulator */ + unsigned int hoff; /* 0xFC04 Offset to H edge of screen */ + unsigned int voff; /* 0xFC06 Offset to V edge of screen */ + unsigned char *sprbase; /* 0xFC08 Base address of sprite */ + unsigned char *colbase; /* 0xFC0A Base address of collision buffer */ + unsigned char *vidadr; /* 0xFC0C Current vid buffer address */ + unsigned char *coladr; /* 0xFC0E Current col buffer address */ + unsigned char *scbnext; /* 0xFC10 Address of next SCB */ + unsigned char *sprdline; /* 0xFC12 start of sprite data line address */ + unsigned int hposstrt; /* 0xFC14 start hpos */ + unsigned int vposstrt; /* 0xFC16 start vpos */ + unsigned int sprhsize; /* 0xFC18 sprite h size */ + unsigned int sprvsize; /* 0xFC1A sprite v size */ + unsigned int stretchl; /* 0xFC1C H size adder */ + unsigned int tilt; /* 0xFC1E H pos adder */ + unsigned int sprdoff; /* 0xFC20 offset to next sprite data line */ + unsigned int sprvpos; /* 0xFC22 current vpos */ + unsigned int colloff; /* 0xFC24 offset to collision depository */ + unsigned int vsizeacc; /* 0xFC26 vertical size accumulator */ + unsigned int hsizeoff; /* 0xFC28 horizontal size offset */ + unsigned int vsizeoff; /* 0xFC2A vertical size offset */ + unsigned char *scbaddr; /* 0xFC2C address of current SCB */ + unsigned char *procaddr; /* 0xFC2E address of current spr data proc */ + unsigned char unused0[32]; /* 0xFC30 - 0xFC4F reserved/unused */ + unsigned char unused1[2]; /* 0xFC50 - 0xFC51 do not use */ + unsigned char mathd; /* 0xFC52 */ + unsigned char mathc; /* 0xFC53 */ + unsigned char mathb; /* 0xFC54 */ + unsigned char matha; /* 0xFC55 write starts a multiply operation */ + unsigned char mathp; /* 0xFC56 */ + unsigned char mathn; /* 0xFC57 */ + unsigned char unused2[8]; /* 0xFC58 - 0xFC5F do not use */ + unsigned char mathh; /* 0xFC60 */ + unsigned char mathg; /* 0xFC61 */ + unsigned char mathf; /* 0xFC62 */ + unsigned char mathe; /* 0xFC63 write starts a divide operation */ + unsigned char unused3[8]; /* 0xFC64 - 0xFC6B do not use */ + unsigned char mathm; /* 0xFC6C */ + unsigned char mathl; /* 0xFC6D */ + unsigned char mathk; /* 0xFC6E */ + unsigned char mathj; /* 0xFC6F */ + unsigned char unused4[16]; /* 0xFC70 - 0xFC7F do not use */ + unsigned char sprctl0; /* 0xFC80 sprite control bits 0 */ + unsigned char sprctl1; /* 0xFC81 sprite control bits 1 */ + unsigned char sprcoll; /* 0xFC82 sprite collision number */ + unsigned char sprinit; /* 0xFC83 sprite initialization bits */ + unsigned char unused5[4]; /* 0xFC84 - 0xFC87 unused */ + unsigned char suzyhrev; /* 0xFC88 suzy hardware rev */ + unsigned char suzysrev; /* 0xFC89 suzy software rev */ + unsigned char unused6[6]; /* 0xFC8A - 0xFC8F unused */ + unsigned char suzybusen; /* 0xFC90 suzy bus enable */ + unsigned char sprgo; /* 0xFC91 sprite process start bit */ + unsigned char sprsys; /* 0xFC92 sprite system control bits */ + unsigned char unused7[29]; /* 0xFC93 - 0xFCAF unused */ + unsigned char joystick; /* 0xFCB0 joystick and buttons */ + unsigned char switches; /* 0xFCB1 other switches */ + unsigned char cart0; /* 0xFCB2 cart0 r/w */ + unsigned char cart1; /* 0xFCB3 cart1 r/w */ + unsigned char unused8[8]; /* 0xFCB4 - 0xFCBF unused */ + unsigned char leds; /* 0xFCC0 leds */ + unsigned char unused9; /* 0xFCC1 unused */ + unsigned char parstat; /* 0xFCC2 parallel port status */ + unsigned char pardata; /* 0xFCC3 parallel port data */ + unsigned char howie; /* 0xFCC4 howie (?) */ + /* 0xFCC5 - 0xFCFF unused */ }; /* Hardware math registers */ diff --git a/include/lynx.h b/include/lynx.h index fe4006461..259b3da71 100644 --- a/include/lynx.h +++ b/include/lynx.h @@ -80,29 +80,29 @@ #define DYN_DRV 0 /* Addresses of static drivers */ -extern void lynx_stdjoy_joy[]; // Referred to by joy_static_stddrv[] -extern void lynx_comlynx_ser[]; // Referred to by ser_static_stddrv[] -extern void lynx_160_102_16_tgi[]; // Referred to by tgi_static_stddrv[] +extern void lynx_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */ +extern void lynx_comlynx_ser[]; /* Referred to by ser_static_stddrv[] */ +extern void lynx_160_102_16_tgi[]; /* Referred to by tgi_static_stddrv[] */ /* Sound support */ -void lynx_snd_init (void); // Initialize the sound driver -void lynx_snd_pause (void); // Pause sound -void lynx_snd_continue (void); // Continue sound after pause -void __fastcall__ lynx_snd_play (unsigned char channel, unsigned char *music); // Play tune on channel -void lynx_snd_stop (void); // Stop sound on all channels -void __fastcall__ lynx_snd_stop_channel (unsigned char channel); // Stop sound on all channels -unsigned char lynx_snd_active(void); // Show which channels are active +void lynx_snd_init (void); /* Initialize the sound driver */ +void lynx_snd_pause (void); /* Pause sound */ +void lynx_snd_continue (void); /* Continue sound after pause */ +void __fastcall__ lynx_snd_play (unsigned char channel, unsigned char *music); /* Play tune on channel */ +void lynx_snd_stop (void); /* Stop sound on all channels */ +void __fastcall__ lynx_snd_stop_channel (unsigned char channel); /* Stop sound on all channels */ +unsigned char lynx_snd_active(void); /* Show which channels are active */ /* Cartridge access */ -void __fastcall__ lynx_load (int file_number); // Load a file into RAM using a zero-based index -void __fastcall__ lynx_exec (int file_number); // Load a file into ram and execute it +void __fastcall__ lynx_load (int file_number); /* Load a file into RAM using a zero-based index */ +void __fastcall__ lynx_exec (int file_number); /* Load a file into ram and execute it */ /* EEPROM access */ -unsigned __fastcall__ lynx_eeprom_read (unsigned char cell); // Read a 16 bit word from the given address -unsigned __fastcall__ lynx_eeprom_write (unsigned char cell, unsigned val); // Write the word at the given address -void __fastcall__ lynx_eeprom_erase (unsigned char cell); // Clear the word at the given address -unsigned __fastcall__ lynx_eeread (unsigned cell); // Read a 16 bit word from the given address 93C46, 93C66 or 93C86 -unsigned __fastcall__ lynx_eewrite (unsigned cell, unsigned val); // Write the word at the given address 93C46, 93C66 or 93C86 +unsigned __fastcall__ lynx_eeprom_read (unsigned char cell); /* Read a 16 bit word from the given address */ +unsigned __fastcall__ lynx_eeprom_write (unsigned char cell, unsigned val); /* Write the word at the given address */ +void __fastcall__ lynx_eeprom_erase (unsigned char cell); /* Clear the word at the given address */ +unsigned __fastcall__ lynx_eeread (unsigned cell); /* Read a 16 bit word from the given address 93C46, 93C66 or 93C86 */ +unsigned __fastcall__ lynx_eewrite (unsigned cell, unsigned val); /* Write the word at the given address 93C46, 93C66 or 93C86 */ /* TGI extras */ #define tgi_sprite(spr) tgi_ioctl(0, spr) @@ -117,11 +117,11 @@ unsigned __fastcall__ lynx_eewrite (unsigned cell, unsigned val); // Write the w #include <_mikey.h> #define MIKEY (*(struct __mikey *)0xFD00) -#define _MIKEY_TIMERS (*(struct _mikey_all_timers *) 0xFD00) // mikey_timers[8] -#define _HBL_TIMER (*(struct _mikey_timer *) 0xFD00) // timer0 (HBL) -#define _VBL_TIMER (*(struct _mikey_timer *) 0xFD08) // timer2 (VBL) -#define _UART_TIMER (*(struct _mikey_timer *) 0xFD14) // timer4 (UART) -#define _VIDDMA (*(unsigned int *) 0xFD92) // dispctl/viddma +#define _MIKEY_TIMERS (*(struct _mikey_all_timers *) 0xFD00) /* mikey_timers[8] */ +#define _HBL_TIMER (*(struct _mikey_timer *) 0xFD00) /* timer0 (HBL) */ +#define _VBL_TIMER (*(struct _mikey_timer *) 0xFD08) /* timer2 (VBL) */ +#define _UART_TIMER (*(struct _mikey_timer *) 0xFD14) /* timer4 (UART) */ +#define _VIDDMA (*(unsigned int *) 0xFD92) /* DISPCTL/VIDDMA */ #include <_suzy.h> #define SUZY (*(volatile struct __suzy*)0xFC00)