From becc1c3e28391a81670682325b47e79412971886 Mon Sep 17 00:00:00 2001 From: Adrian Siekierka Date: Thu, 4 Apr 2024 06:06:29 +0200 Subject: [PATCH] [lynx] Initial target support (#329) --- README.md | 3 + mos-platform/CMakeLists.txt | 2 + mos-platform/lynx-bll/CMakeLists.txt | 9 + mos-platform/lynx-bll/link.ld | 38 ++++ mos-platform/lynx/CMakeLists.txt | 25 ++ mos-platform/lynx/_mikey.h | 115 ++++++++++ mos-platform/lynx/_suzy.h | 326 +++++++++++++++++++++++++++ mos-platform/lynx/clang.cfg | 3 + mos-platform/lynx/lynx.h | 79 +++++++ 9 files changed, 600 insertions(+) create mode 100644 mos-platform/lynx-bll/CMakeLists.txt create mode 100644 mos-platform/lynx-bll/link.ld create mode 100644 mos-platform/lynx/CMakeLists.txt create mode 100644 mos-platform/lynx/_mikey.h create mode 100644 mos-platform/lynx/_suzy.h create mode 100644 mos-platform/lynx/clang.cfg create mode 100644 mos-platform/lynx/lynx.h diff --git a/README.md b/README.md index a0f3228a..a6c79e0a 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ The LLVM-MOS compiler toolchain and platform libraries. to [512 KiB](https://github.com/atari800/atari800/blob/ATARI800_5_2_0/DOC/cart.txt#L65) - Compatible with SIC! [128 KiB](https://github.com/atari800/atari800/blob/ATARI800_5_2_0/DOC/cart.txt#L88) to [512 KiB](https://github.com/atari800/atari800/blob/ATARI800_5_2_0/DOC/cart.txt#L90) +- [Atari Lynx](https://en.wikipedia.org/wiki/Atari_Lynx) + - BLL format ".o" executable file - [Ben Eater's Breadboard 6502 Computer](https://eater.net/6502) - [Commander X16](https://www.commanderx16.com/) - [Commodore 64](https://en.wikipedia.org/wiki/Commodore_64) @@ -154,6 +156,7 @@ executables and libraries for that target. | Atari 8-bit | MegaCart cartridge | `mos-atari8-cart-megacart-clang` | | Atari 8-bit | Standard cartridge | `mos-atari8-cart-std-clang` | | Atari 8-bit | XEGS cartridge | `mos-atari8-cart-xegs-clang` | +| Atari Lynx | BLL executable | `mos-lynx-bll-clang` | | Ben Eater's 6502 Breadboard Kit | - | `mos-eater-clang` | | Commander X16 | - | `mos-cx16-clang` | | Commodore | 64 | `mos-c64-clang` | diff --git a/mos-platform/CMakeLists.txt b/mos-platform/CMakeLists.txt index adc9f062..603741aa 100644 --- a/mos-platform/CMakeLists.txt +++ b/mos-platform/CMakeLists.txt @@ -77,6 +77,8 @@ add_subdirectory(osi-c1p) add_subdirectory(dodo) add_subdirectory(pet) add_subdirectory(rpc8e) +add_subdirectory(lynx) +add_subdirectory(lynx-bll) add_subdirectory(pce-common) add_subdirectory(pce) add_subdirectory(pce-cd) diff --git a/mos-platform/lynx-bll/CMakeLists.txt b/mos-platform/lynx-bll/CMakeLists.txt new file mode 100644 index 00000000..78aa5f42 --- /dev/null +++ b/mos-platform/lynx-bll/CMakeLists.txt @@ -0,0 +1,9 @@ +platform(lynx-bll COMPLETE PARENT lynx) + +if(NOT CMAKE_CROSSCOMPILING) + return() +endif() + +install(FILES + link.ld +TYPE LIB) diff --git a/mos-platform/lynx-bll/link.ld b/mos-platform/lynx-bll/link.ld new file mode 100644 index 00000000..79b3a1a5 --- /dev/null +++ b/mos-platform/lynx-bll/link.ld @@ -0,0 +1,38 @@ +/* Atari Lynx .bll.o linker script. */ + +/* Provide imaginary (zero page) registers. */ +__rc0 = 0x00; +INCLUDE imag-regs.ld +ASSERT(__rc31 == 0x001f, "Inconsistent zero page map.") + +/* An optimization strategy on Lynx hardware is to reserve memory from + 0xFFF0 down, which is mapped to the graphics hardware but not to the CPU + by default, to store a display screen. */ +PROVIDE(__hiram_reserved_size = 0); +__hiram_start = MIN(0xfc00, 0xfff0 - __hiram_reserved_size); + +MEMORY { + zp : ORIGIN = __rc31 + 1, LENGTH = 0x100 - (__rc31 + 1) + ram (rw) : ORIGIN = 0x200, LENGTH = __hiram_start - 0x200 +} + +REGION_ALIAS("c_readonly", ram) +REGION_ALIAS("c_writeable", ram) + +SECTIONS { INCLUDE c.ld } + +/* Set initial soft stack address to just above last memory address. (It grows down.) */ +__stack = __hiram_start; + +OUTPUT_FORMAT { + SHORT(0x0880) + /* Start address, big-endian. */ + BYTE(ORIGIN(ram) >> 8) + BYTE(ORIGIN(ram) & 0xFF) + /* Length (including header), big-endian. */ + BYTE((__data_end - ORIGIN(ram) + 10) >> 8) + BYTE((__data_end - ORIGIN(ram) + 10) & 0xFF) + SHORT(0x5342) /* BS93 */ + SHORT(0x3339) + TRIM(ram) +} diff --git a/mos-platform/lynx/CMakeLists.txt b/mos-platform/lynx/CMakeLists.txt new file mode 100644 index 00000000..95713d4a --- /dev/null +++ b/mos-platform/lynx/CMakeLists.txt @@ -0,0 +1,25 @@ +platform(lynx PARENT common) + +if(NOT CMAKE_CROSSCOMPILING) + return() +endif() + +include_directories(BEFORE SYSTEM .) + +install(FILES + _mikey.h + _suzy.h + lynx.h +TYPE INCLUDE) + +add_platform_library(lynx-crt0) +merge_libraries(lynx-crt0 + common-copy-zp-data + common-init-stack + common-zero-bss + common-exit-loop +) + +add_platform_library(lynx-c) +target_include_directories(lynx-c SYSTEM BEFORE PUBLIC .) +target_link_libraries(lynx-c PRIVATE common-asminc) diff --git a/mos-platform/lynx/_mikey.h b/mos-platform/lynx/_mikey.h new file mode 100644 index 00000000..51064bf2 --- /dev/null +++ b/mos-platform/lynx/_mikey.h @@ -0,0 +1,115 @@ +// Copyright 2024 LLVM-MOS Project +// Licensed under the Apache License, Version 2.0 with LLVM Exceptions. +// See https://github.com/llvm-mos/llvm-mos-sdk/blob/main/LICENSE for license +// information. + +// Originally from cc65. Modified from original version. + +// clang-format off + +/*****************************************************************************/ +/* */ +/* _mikey.h */ +/* */ +/* Atari Lynx, Mikey chip register hardware structures */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + +#ifndef __MIKEY_H +#define __MIKEY_H + +/* timer structure */ +typedef struct _mikey_timer { + unsigned char reload; + unsigned char control; + unsigned char count; + unsigned char control2; +} _mikey_timer; + +typedef struct _mikey_all_timers { + struct _mikey_timer timer[8]; +} _mikey_all_timers; + +/* audio channel structure */ +typedef struct _mikey_audio { + unsigned char volume; + unsigned char feedback; + unsigned char dac; + unsigned char shiftlo; + unsigned char reload; + unsigned char control; + unsigned char count; + unsigned char other; +} _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 +}; + + +#endif + diff --git a/mos-platform/lynx/_suzy.h b/mos-platform/lynx/_suzy.h new file mode 100644 index 00000000..a0005869 --- /dev/null +++ b/mos-platform/lynx/_suzy.h @@ -0,0 +1,326 @@ +// Copyright 2024 LLVM-MOS Project +// Licensed under the Apache License, Version 2.0 with LLVM Exceptions. +// See https://github.com/llvm-mos/llvm-mos-sdk/blob/main/LICENSE for license +// information. + +// Originally from cc65. Modified from original version. + +// clang-format off + +/*****************************************************************************/ +/* */ +/* _suzy.h */ +/* */ +/* Atari Lynx, Suzy chip register hardware structures */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + +#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 + +/* Switches $FCB1 */ +#define BUTTON_PAUSE 0x01 + + +/* 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 + + +/* 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 + +typedef struct SCB_REHVST_PAL { // SCB with all attributes + unsigned char sprctl0; + unsigned char sprctl1; + unsigned char sprcoll; + char *next; + unsigned char *data; + signed int hpos; + signed int vpos; + unsigned int hsize; + unsigned int vsize; + unsigned int stretch; + unsigned int tilt; + unsigned char penpal[8]; +} SCB_REHVST_PAL; + +typedef struct SCB_REHVST { // SCB without pallette + unsigned char sprctl0; + unsigned char sprctl1; + unsigned char sprcoll; + char *next; + unsigned char *data; + signed int hpos; + signed int vpos; + unsigned int hsize; + unsigned int vsize; + unsigned int stretch; + unsigned int tilt; +} SCB_REHVST; + +typedef struct SCB_REHV { // SCB without stretch/tilt + unsigned char sprctl0; + unsigned char sprctl1; + unsigned char sprcoll; + char *next; + unsigned char *data; + signed int hpos; + signed int vpos; + unsigned int hsize; + unsigned int vsize; +} SCB_REHV; + +typedef struct SCB_REHV_PAL { // SCB without str/tilt, w/ penpal + unsigned char sprctl0; + unsigned char sprctl1; + unsigned char sprcoll; + char *next; + unsigned char *data; + signed int hpos; + signed int vpos; + unsigned int hsize; + unsigned int vsize; + unsigned char penpal[8]; +} SCB_REHV_PAL; + +typedef struct SCB_REHVS { // SCB w/o tilt & penpal + unsigned char sprctl0; + unsigned char sprctl1; + unsigned char sprcoll; + char *next; + unsigned char *data; + signed int hpos; + signed int vpos; + unsigned int hsize; + unsigned int vsize; + unsigned int stretch; +} SCB_REHVS; + +typedef struct SCB_REHVS_PAL { // SCB w/o tilt w/penpal + unsigned char sprctl0; + unsigned char sprctl1; + unsigned char sprcoll; + char *next; + unsigned char *data; + signed int hpos; + signed int vpos; + unsigned int hsize; + unsigned int vsize; + unsigned int stretch; + unsigned char penpal[8]; +} SCB_REHVS_PAL; + +typedef struct SCB_RENONE { // SCB w/o size/stretch/tilt/pal + unsigned char sprctl0; + unsigned char sprctl1; + unsigned char sprcoll; + char *next; + unsigned char *data; + signed int hpos; + signed int vpos; +} SCB_RENONE; + +typedef struct SCB_RENONE_PAL { // SCB w/o size/str/tilt w/penpal + unsigned char sprctl0; + unsigned char sprctl1; + unsigned char sprcoll; + char *next; + unsigned char *data; + signed int hpos; + signed int vpos; + unsigned char penpal[8]; +} SCB_RENONE_PAL; + +typedef struct PENPAL_4 { + unsigned char penpal[8]; +} PENPAL_4; + +typedef struct PENPAL_3 { + unsigned char penpal[4]; +} PENPAL_3; + +typedef struct PENPAL_2 { + unsigned char penpal[2]; +} PENPAL_2; + +typedef struct PENPAL_1 { + unsigned char penpal[1]; +} PENPAL_1; + +/* Misc system defines */ + +/* 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 + + +/* Suzy Hardware Registers */ +struct __suzy { + unsigned int 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 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 + 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 + 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 +}; + + +#endif + diff --git a/mos-platform/lynx/clang.cfg b/mos-platform/lynx/clang.cfg new file mode 100644 index 00000000..8afd19a0 --- /dev/null +++ b/mos-platform/lynx/clang.cfg @@ -0,0 +1,3 @@ +-mcpu=mos65c02 +-D__LYNX__ +-mlto-zp=224 diff --git a/mos-platform/lynx/lynx.h b/mos-platform/lynx/lynx.h new file mode 100644 index 00000000..daee1e30 --- /dev/null +++ b/mos-platform/lynx/lynx.h @@ -0,0 +1,79 @@ +// Copyright 2024 LLVM-MOS Project +// Licensed under the Apache License, Version 2.0 with LLVM Exceptions. +// See https://github.com/llvm-mos/llvm-mos-sdk/blob/main/LICENSE for license +// information. + +// Originally from cc65. Modified from original version. + +// clang-format off + +/*****************************************************************************/ +/* */ +/* lynx.h */ +/* */ +/* Lynx system-specific definitions */ +/* */ +/* */ +/* */ +/* (C) 2003 Shawn Jefferson */ +/* */ +/* Adapted with many changes Ullrich von Bassewitz, 2004-10-09 */ +/* */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + +#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 + +/* Masks for joy_read */ +#define JOY_UP_MASK 0x80 +#define JOY_DOWN_MASK 0x40 +#define JOY_LEFT_MASK 0x20 +#define JOY_RIGHT_MASK 0x10 +#define JOY_BTN_1_MASK 0x01 +#define JOY_BTN_2_MASK 0x02 + +#define JOY_BTN_A_MASK JOY_BTN_1_MASK +#define JOY_BTN_B_MASK JOY_BTN_2_MASK + +#define JOY_BTN_A(v) ((v) & JOY_BTN_A_MASK) +#define JOY_BTN_B(v) ((v) & JOY_BTN_B_MASK) + +/* Define Hardware */ +#include <_mikey.h> +#define MIKEY (*(volatile struct __mikey *)0xFD00) + +#define _MIKEY_TIMERS (*(volatile struct _mikey_all_timers *) 0xFD00) // mikey_timers[8] +#define _HBL_TIMER (*(volatile struct _mikey_timer *) 0xFD00) // timer0 (HBL) +#define _VBL_TIMER (*(volatile struct _mikey_timer *) 0xFD08) // timer2 (VBL) +#define _UART_TIMER (*(volatile struct _mikey_timer *) 0xFD14) // timer4 (UART) +#define _VIDDMA (*(volatile unsigned int *) 0xFD92) // dispctl/viddma + +#include <_suzy.h> +#define SUZY (*(volatile struct __suzy*)0xFC00) + +/* End of lynx.h */ +#endif