80 column video

This commit is contained in:
tudnai 2020-04-27 07:26:04 -07:00
parent 15911de276
commit 91fd9ac8f9
8 changed files with 327 additions and 75 deletions

View File

@ -795,7 +795,7 @@
<subviews>
<textField canDrawConcurrently="YES" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" mirrorLayoutDirectionWhenInternationalizing="never" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="iIF-Q5-Onc">
<rect key="frame" x="0.0" y="0.0" width="1152" height="800"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" enabled="NO" allowsUndo="NO" sendsActionOnEndEditing="YES" state="on" baseWritingDirection="leftToRight" title="Display Background" drawsBackground="YES" id="cIa-Sd-4OZ">
<textFieldCell key="cell" lineBreakMode="truncatingTail" enabled="NO" refusesFirstResponder="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" state="on" baseWritingDirection="leftToRight" title="Display Background" drawsBackground="YES" id="cIa-Sd-4OZ">
<font key="font" metaFont="system"/>
<color key="textColor" red="0.078431372549019607" green="0.10980392156862745" blue="0.078431372549019607" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" red="0.078431372549019607" green="0.10980392156862745" blue="0.078431372549019607" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@ -859,7 +859,7 @@
<constraints>
<constraint firstAttribute="height" constant="21" id="t2i-0h-wau"/>
</constraints>
<buttonCell key="cell" type="push" title="Power" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="hmD-vF-EXJ">
<buttonCell key="cell" type="push" title="Power" bezelStyle="rounded" alignment="center" refusesFirstResponder="YES" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="hmD-vF-EXJ">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
@ -872,7 +872,7 @@
<constraints>
<constraint firstAttribute="height" constant="21" id="sbX-nh-SV3"/>
</constraints>
<buttonCell key="cell" type="push" title="Reset" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="LHj-7W-LwD">
<buttonCell key="cell" type="push" title="Reset" bezelStyle="rounded" alignment="center" refusesFirstResponder="YES" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="LHj-7W-LwD">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<connections>
@ -902,7 +902,7 @@
<constraints>
<constraint firstAttribute="height" constant="17" id="ai1-6C-5tW"/>
</constraints>
<textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="Label" id="FBZ-dh-6Fs">
<textFieldCell key="cell" lineBreakMode="clipping" refusesFirstResponder="YES" alignment="center" title="Label" id="FBZ-dh-6Fs">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
@ -913,7 +913,7 @@
<constraints>
<constraint firstAttribute="height" constant="17" id="xCE-LE-hVy"/>
</constraints>
<textFieldCell key="cell" lineBreakMode="clipping" alignment="left" title="CPU Speed" id="b3T-0k-ama">
<textFieldCell key="cell" lineBreakMode="clipping" refusesFirstResponder="YES" alignment="left" title="CPU Speed" id="b3T-0k-ama">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
@ -921,7 +921,7 @@
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="7Pw-e8-92m">
<rect key="frame" x="-1" y="119" width="55" height="18"/>
<buttonCell key="cell" type="radio" title="1.023" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="AgQ-Np-TYQ">
<buttonCell key="cell" type="radio" title="1.023" bezelStyle="regularSquare" imagePosition="left" alignment="left" refusesFirstResponder="YES" state="on" inset="2" id="AgQ-Np-TYQ">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
@ -931,7 +931,7 @@
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="hU1-g7-CCX">
<rect key="frame" x="-1" y="95" width="30" height="18"/>
<buttonCell key="cell" type="radio" title="2" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="nfH-ww-Ofp">
<buttonCell key="cell" type="radio" title="2" bezelStyle="regularSquare" imagePosition="left" alignment="left" refusesFirstResponder="YES" inset="2" id="nfH-ww-Ofp">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
@ -941,7 +941,7 @@
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Hfg-DD-meM">
<rect key="frame" x="-1" y="71" width="31" height="18"/>
<buttonCell key="cell" type="radio" title="4" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="dqL-yg-qaX">
<buttonCell key="cell" type="radio" title="4" bezelStyle="regularSquare" imagePosition="left" alignment="left" refusesFirstResponder="YES" inset="2" id="dqL-yg-qaX">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
@ -951,7 +951,7 @@
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="OsQ-RW-v8K">
<rect key="frame" x="-1" y="47" width="37" height="18"/>
<buttonCell key="cell" type="radio" title="10" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="3Ve-WW-CIS">
<buttonCell key="cell" type="radio" title="10" bezelStyle="regularSquare" imagePosition="left" alignment="left" refusesFirstResponder="YES" inset="2" id="3Ve-WW-CIS">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
@ -961,7 +961,7 @@
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="vGb-dz-KHi">
<rect key="frame" x="-1" y="23" width="45" height="18"/>
<buttonCell key="cell" type="radio" title="100" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="BUX-kX-vwG">
<buttonCell key="cell" type="radio" title="100" bezelStyle="regularSquare" imagePosition="left" alignment="left" refusesFirstResponder="YES" inset="2" id="BUX-kX-vwG">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
@ -971,7 +971,7 @@
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="umb-DW-vGc">
<rect key="frame" x="-1" y="-1" width="47" height="18"/>
<buttonCell key="cell" type="radio" title="666" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="8VU-4B-7Pe">
<buttonCell key="cell" type="radio" title="666" bezelStyle="regularSquare" imagePosition="left" alignment="left" refusesFirstResponder="YES" inset="2" id="8VU-4B-7Pe">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>

View File

@ -678,7 +678,7 @@ class HiRes: NSView {
if videoMode.mixed == 1 {
height = HiRes.MixedHeight
}
if videoMode.page == 1 {
if videoMode.page2 == 1 {
HiResBufferPointer = HiResBuffer2
}
else {

View File

@ -44,7 +44,7 @@ func spk_dn_play() {
import Metal
#endif
class ViewController: NSViewController {
class ViewController: NSViewController {
@IBOutlet weak var displayField: NSTextField!
@IBOutlet weak var display: NSTextFieldCell!
@ -139,21 +139,32 @@ class ViewController: NSViewController {
static let textBaseAddr = 0x400
static let textBufferSize = 0x400
let textLines = 24
let textCols = 40
let lineEndChars = 1
// static only needed to be able to initialize things
static let textLines = 24
static let textCols = 40
static let lineEndChars = 1
// these are needed to be able to easy access to these constants from instances
let textLines = ViewController.textLines
let textCols = ViewController.textCols
let lineEndChars = ViewController.lineEndChars
var frameCnt = 0
// let spaceChar : Character = "\u{E17F}"
// let blockChar : Character = "\u{E07F}"
let spaceChar : Character = " "
let blockChar : Character = ""
var flashingSpace : Character = " "
// static let spaceChar : Character = " "
// static let blockChar : Character = ""
// static var flashingSpace : Character = " "
let ramBufferPointer = UnsafeRawBufferPointer(start: RAM, count: 64 * 1024)
let textBufferPointer = UnsafeRawBufferPointer(start: RAM + textBaseAddr, count: textBufferSize)
var txtClear = [Character](repeating: " ", count: textBufferSize)
var txtArr = [Character](repeating: " ", count: textBufferSize)
let textAuxBufferPointer = UnsafeRawBufferPointer(start: AUX_VID_RAM, count: textBufferSize * 2)
static let textArraySize = textLines * (textCols + lineEndChars) + textCols * 2
var txtClear = [Character](repeating: " ", count: textArraySize * 2)
var txtArr = [Character](repeating: " ", count: textArraySize * 2)
var s = String()
@ -185,6 +196,10 @@ class ViewController: NSViewController {
var ddd = 9;
override var acceptsFirstResponder: Bool {
return true
}
override func keyDown(with event: NSEvent) {
print("KBD Event")
@ -262,6 +277,7 @@ class ViewController: NSViewController {
}
#endif
}
}
override func keyUp(with event: NSEvent) {
@ -351,6 +367,8 @@ class ViewController: NSViewController {
var was = 0;
var currentVideoMode = videoMode
func Update() {
#if SPEEDTEST
@ -396,20 +414,45 @@ class ViewController: NSViewController {
let byte = textBufferPointer[ textLineOfs[y] + x ]
let idx = Int(byte);
let chr = ViewController.charConvTbl[idx]
if videoMode.col80 == 0 {
txtArr[ y * (textCols + lineEndChars) + x ] = chr
}
else {
txtArr[ y * (textCols * 2 + lineEndChars) + x * 2 + 1] = chr
// is it a cursor? (slashing space)
// if ( chr == "blockChar" ) {
// chr = flashingSpace
// }
txtArr[ y * (textCols + lineEndChars) + x ] = chr
let byte = textAuxBufferPointer[ textLineOfs[y] + x ]
let idx = Int(byte);
let chr = ViewController.charConvTbl[idx]
txtArr[ y * (textCols * 2 + lineEndChars) + x * 2] = chr
}
}
if videoMode.col80 == 0 {
txtArr[ y * (textCols + lineEndChars) + textCols ] = "\n"
}
else {
txtArr[ y * (textCols * 2 + lineEndChars) + textCols * 2] = "\n"
}
txtArr[ y * (textCols + lineEndChars) + textCols ] = "\n"
}
txt = String(txtArr)
DispatchQueue.main.async {
if videoMode.col80 != self.currentVideoMode.col80 {
self.currentVideoMode.col80 = videoMode.col80
if let fontSize = self.display.font?.pointSize {
if videoMode.col80 == 1 {
self.display.font = NSFont(name: "PRNumber3", size: fontSize)
}
else {
self.display.font = NSFont(name: "PrintChar21", size: fontSize)
}
}
}
self.display.stringValue = txt
// self.display.stringValue = "testing\nit\nout"
@ -456,9 +499,9 @@ class ViewController: NSViewController {
override func viewDidLoad() {
super.viewDidLoad()
for y in 0 ... textLines - 1 {
txtClear[ y * (textCols + lineEndChars) + textCols ] = "\n"
}
// for y in 0 ... textLines - 1 {
// txtClear[ y * (textCols + lineEndChars) + textCols * 2 + 1 ] = "\n"
// }
woz_loadFile( Bundle.main.resourcePath, "Apple DOS 3.3 January 1983.woz" )
@ -496,13 +539,20 @@ class ViewController: NSViewController {
// return $0
// }
// // NSEvent.removeMonitor(NSEvent.EventType.keyDown)
// NSEvent.addLocalMonitorForEvents(matching: .keyDown) {
//// print("keyDown event")
// self.keyDown(with: $0)
// NSEvent.removeMonitor(NSEvent.EventType.keyDown)
NSEvent.addLocalMonitorForEvents(matching: .keyDown) {
// print("keyDown event")
self.keyDown(with: $0)
return nil
// return $0
// }
}
NSEvent.addLocalMonitorForEvents(matching: .keyUp) {
// print("keyUp event")
self.keyUp(with: $0)
return nil
// return $0
}
displayField.maximumNumberOfLines = textLines
displayField.preferredMaxLayoutWidth = displayField.frame.width

View File

@ -239,8 +239,8 @@ class ViewController: UIViewController {
var flashingSpace : Character = " "
let ramBufferPointer = UnsafeRawBufferPointer(start: RAM, count: 64 * 1024)
let textBufferPointer = UnsafeRawBufferPointer(start: RAM + textBaseAddr, count: textBufferSize)
let txtClear = [Character](repeating: " ", count: textBufferSize)
let textBufferPointer = UnsafeRawBufferPointer(start: RAM + textBaseAddr, count: textBufferSize * 2)
let txtClear = [Character](repeating: " ", count: textBufferSize * 2)
var txtArr = txtClear
var s = String()

View File

@ -881,6 +881,8 @@ void rom_loadFile( const char * bundlePath, const char * filename ) {
read_rom( bundlePath, filename, Apple2_16K_ROM, 0);
memcpy(Apple2_12K_ROM + 0x0000, Apple2_16K_ROM + 0x1000, sizeof(Apple2_12K_ROM));
memcpy(Apple2_64K_RAM + 0xC000, Apple2_16K_ROM, 0x1000);
SWITCH_CX_ROM( RAM_PG_RD_TBL, 0xC0, Apple2_16K_ROM, 0x00);
}
else if ( flen == 12 * KB ) {

View File

@ -99,7 +99,9 @@ typedef union videoMode_u {
uint8_t altChr : 1; // 0: normal 1: alternate character set
uint8_t mixed : 1; // 0: no mix 1: mixed graphics and text when in graphics mode
uint8_t hires : 1; // 0: loRes 1: hiRes
uint8_t page : 1; // 0: page 1 1: page 2 (aux video memory)
uint8_t page2 : 1; // 0: page 1 1: page 2 (aux video memory)
uint8_t intCxROM : 1; // 0: Slot Cx ROM 1: Internal Cx ROM
uint8_t slotC3ROM : 1; // 0: Internal ROM 1: Slot 3 ROM
};
uint8_t mode;
} videoMode_t;
@ -109,6 +111,7 @@ extern videoMode_t videoMode;
extern m6502_t m6502;
extern uint8_t * RAM;
extern uint8_t * AUX_VID_RAM;
extern uint32_t * videoMemPtr;
extern void hires_Update(void);

View File

@ -118,6 +118,20 @@ INLINE void STR( uint8_t * dst, uint8_t src ) {
return;
}
}
// else if ( ( addr >= 0x400 ) && ( addr < 0x800 ) ) {
// // Peripheral-card scratchpad RAM locations should be available on both memory
// if ( ( ( addr >= 0x478 ) && ( addr <= 0x47F ) )
// || ( ( addr >= 0x4F8 ) && ( addr <= 0x4FF ) )
// || ( ( addr >= 0x578 ) && ( addr <= 0x57F ) )
// || ( ( addr >= 0x5F8 ) && ( addr <= 0x5FF ) )
// || ( ( addr >= 0x678 ) && ( addr <= 0x67F ) )
// || ( ( addr >= 0x6F8 ) && ( addr <= 0x6FF ) )
// || ( ( addr >= 0x778 ) && ( addr <= 0x77F ) )
// || ( ( addr >= 0x7F8 ) && ( addr <= 0x7FF ) )
// ) {
// AUX_VID_RAM[ addr - 0x400 ] = src;
// }
// }
*dst = src;

View File

@ -30,10 +30,13 @@ videoMode_t videoMode = { 1 }; // 40 col text, page 1
uint8_t Apple2_Dummy_Page[ 1 * PG ]; // Dummy Page for discarding data
uint8_t Apple2_Dummy_RAM[ 4 * KB ]; // Dummy RAM for discarding data
uint8_t Apple2_512_AUX[ 2 * PG ] = {0}; // Auxiliary bank for page 0 and 1
uint8_t Apple2_VID_AUX[ 2 * KB ] = {0}; // Auxiliary RAM for video page 2
uint8_t Apple2_12K_ROM[ 12 * KB ] = {0}; // ROM D0, D8, E0, E8, F0, F8
uint8_t Apple2_16K_ROM[ 16 * KB ] = {0}; // ROM C0, C8, D0, D8, E0, E8, F0, F8
uint8_t Apple2_16K_RAM[ 16 * KB ] = {0}; // 16K Memory Expansion Card
uint8_t Apple2_64K_RAM[ 64 * KB ] = {0}; // Main Memory
uint8_t * AUX_VID_RAM = Apple2_VID_AUX; // Pointer to Auxiliary Video Memory
uint8_t * RAM = Apple2_64K_RAM; // Pointer to the main memory so we can use this from Swift
@ -58,6 +61,38 @@ uint8_t * RAM = Apple2_64K_RAM; // Pointer to the main memory so we
DEF_RAM_PAGE(mem, (pg) + 0x0E), \
DEF_RAM_PAGE(mem, (pg) + 0x0F)
#define SWITCH_VIDEO_RAM( tbl,tpg, mem,mpg ) \
(tbl)[ (tpg) + 0x00 ] = DEF_RAM_PAGE(mem, (mpg) + 0x00); \
(tbl)[ (tpg) + 0x01 ] = DEF_RAM_PAGE(mem, (mpg) + 0x01); \
(tbl)[ (tpg) + 0x02 ] = DEF_RAM_PAGE(mem, (mpg) + 0x02); \
(tbl)[ (tpg) + 0x03 ] = DEF_RAM_PAGE(mem, (mpg) + 0x03);
// (tbl)[ (tpg) + 0x04 ] = DEF_RAM_PAGE(mem, (mpg) + 0x04); \
// (tbl)[ (tpg) + 0x05 ] = DEF_RAM_PAGE(mem, (mpg) + 0x05); \
// (tbl)[ (tpg) + 0x06 ] = DEF_RAM_PAGE(mem, (mpg) + 0x06); \
// (tbl)[ (tpg) + 0x07 ] = DEF_RAM_PAGE(mem, (mpg) + 0x07);
#define SWITCH_ROM_PAGE( tbl,tpg, mem,mpg ) \
(tbl)[ (tpg) ] = DEF_RAM_PAGE( mem, (mpg) );
#define SWITCH_CX_ROM( tbl,tpg, mem,mpg ) \
(tbl)[ (tpg) + 0x01 ] = DEF_RAM_PAGE(mem, (mpg) + 0x01); \
(tbl)[ (tpg) + 0x02 ] = DEF_RAM_PAGE(mem, (mpg) + 0x02); \
(tbl)[ (tpg) + 0x03 ] = DEF_RAM_PAGE(mem, (mpg) + 0x03); \
(tbl)[ (tpg) + 0x04 ] = DEF_RAM_PAGE(mem, (mpg) + 0x04); \
(tbl)[ (tpg) + 0x05 ] = DEF_RAM_PAGE(mem, (mpg) + 0x05); \
(tbl)[ (tpg) + 0x06 ] = DEF_RAM_PAGE(mem, (mpg) + 0x06); \
(tbl)[ (tpg) + 0x07 ] = DEF_RAM_PAGE(mem, (mpg) + 0x07); \
(tbl)[ (tpg) + 0x08 ] = DEF_RAM_PAGE(mem, (mpg) + 0x08); \
(tbl)[ (tpg) + 0x09 ] = DEF_RAM_PAGE(mem, (mpg) + 0x09); \
(tbl)[ (tpg) + 0x0A ] = DEF_RAM_PAGE(mem, (mpg) + 0x0A); \
(tbl)[ (tpg) + 0x0B ] = DEF_RAM_PAGE(mem, (mpg) + 0x0B); \
(tbl)[ (tpg) + 0x0C ] = DEF_RAM_PAGE(mem, (mpg) + 0x0C); \
(tbl)[ (tpg) + 0x0D ] = DEF_RAM_PAGE(mem, (mpg) + 0x0D); \
(tbl)[ (tpg) + 0x0E ] = DEF_RAM_PAGE(mem, (mpg) + 0x0E); \
(tbl)[ (tpg) + 0x0F ] = DEF_RAM_PAGE(mem, (mpg) + 0x0F);
#define SWITCH_RAM_PAGE16( tbl,tpg, mem,mpg ) \
(tbl)[ (tpg) + 0x00 ] = DEF_RAM_PAGE(mem, (mpg) + 0x00); \
(tbl)[ (tpg) + 0x01 ] = DEF_RAM_PAGE(mem, (mpg) + 0x01); \
@ -150,7 +185,28 @@ uint8_t * RAM_PG_WR_TBL[256] = {
DEF_RAM_PAGE16( Apple2_64K_RAM, 0xA0),
DEF_RAM_PAGE16( Apple2_64K_RAM, 0xB0),
// I/O Addresses
// DEF_RAM_DUMMY16,
DEF_RAM_PAGE16( Apple2_64K_RAM, 0xC0),
// DEF_RAM_PAGE(Apple2_64K_RAM, 0xC0),
// // SLOT ROM is non-writeable
// DEF_RAM_PAGE(Apple2_Dummy_Page, 0), // 01
// DEF_RAM_PAGE(Apple2_Dummy_Page, 0), // 02
// DEF_RAM_PAGE(Apple2_Dummy_Page, 0), // 03
// DEF_RAM_PAGE(Apple2_Dummy_Page, 0), // 04
// DEF_RAM_PAGE(Apple2_Dummy_Page, 0), // 05
// DEF_RAM_PAGE(Apple2_Dummy_Page, 0), // 06
// DEF_RAM_PAGE(Apple2_Dummy_Page, 0), // 07
// DEF_RAM_PAGE(Apple2_Dummy_Page, 0), // 08
// DEF_RAM_PAGE(Apple2_Dummy_Page, 0), // 09
// DEF_RAM_PAGE(Apple2_Dummy_Page, 0), // 0A
// DEF_RAM_PAGE(Apple2_Dummy_Page, 0), // 0B
// DEF_RAM_PAGE(Apple2_Dummy_Page, 0), // 0C
// DEF_RAM_PAGE(Apple2_Dummy_Page, 0), // 0D
// DEF_RAM_PAGE(Apple2_Dummy_Page, 0), // 0E
// DEF_RAM_PAGE(Apple2_Dummy_Page, 0), // 0F
// NO Writing to the ROM
DEF_RAM_DUMMY16,
DEF_RAM_DUMMY16,
@ -179,31 +235,45 @@ typedef struct MEMcfg_s {
uint8_t WR_RAM : 1;
uint8_t RAM_BANK_2 : 1;
uint8_t AUX_BANK : 1;
uint8_t is80STORE : 1;
} MEMcfg_t;
MEMcfg_t MEMcfg = { 1, 0, 0, 0, 0, 0 };
MEMcfg_t MEMcfg = { 1, 0, 0, 0, 0, 0, 0 };
// https://www.kreativekorp.com/miscpages/a2info/iomemory.shtml
// Comp: O = Apple II+ E = Apple IIe C = Apple IIc G = Apple IIgs
// Act: R = Read W = Write 7 = Bit 7 V = Value
enum mmio {
// Keyboard
io_KBD = 0xC000,
io_KBDSTRB = 0xC010,
io_KBD = 0xC000, // OECG R Last Key Pressed + 128
io_KBDSTRB = 0xC010, // OECG WR Keyboard Strobe
// Audio
io_SPKR = 0xC030,
io_SPKR = 0xC030, // OECG R Toggle Speaker
// Video
io_VID_80col_OFF = 0xC00C,
io_VID_80col_ON = 0xC00D,
io_VID_AltChar_OFF = 0xC00E,
io_VID_AltChar_ON = 0xC00F,
io_80STOREOFF = 0xC000, // ECG W Use $C002-$C005 for Aux Memory
io_80STOREON = 0xC001, // ECG W Use PAGE2 for Aux Memory
io_RD80STORE = 0xC018, // ECG R7 Status of $C002-$C005/PAGE2 for Aux Mem
io_VID_CLR80VID = 0xC00C, // ECG W 40 Columns
io_VID_SET80VID = 0xC00D, // ECG W 80 Columns
io_VID_CLRALTCHAR = 0xC00E, // ECG W Primary Character Set
io_VID_SETALTCHAR = 0xC00F, // ECG W Alternate Character Set
io_VID_ALTCHAR = 0xC01E, // ECG R7 Status of Primary/Alternate Character Set
io_VID_RD80VID = 0xC01F, // ECG R7 Status of 40/80 Columns
io_VID_Text_OFF = 0xC050,
io_VID_Text_ON = 0xC051,
io_VID_Mixed_OFF = 0xC052,
io_VID_Mixed_ON = 0xC053,
io_VID_Page2_OFF = 0xC054,
io_VID_Page2_ON = 0xC055,
io_VID_TXTPAGE1 = 0xC054, // OECG WR Display Page 1
io_VID_TXTPAGE2 = 0xC055, // OECG WR If 80STORE Off: Display Page 2
// ECG WR If 80STORE On: Read/Write Aux Display Mem
io_VID_Hires_OFF = 0xC056,
io_VID_Hires_ON = 0xC057,
io_TAPEIN = 0xC060, // OE R7 Read Cassette Input
// C R7 Status of 80/40 Column Switch
// Game Controller
io_PDL0 = 0xC064,
@ -231,6 +301,14 @@ enum mmio {
io_DISK_SHIFT = 0xC08F,
// Memory
io_SETSLOTCXROM = 0xC006, // E G W Disable Internal ROM / Enable Peripheral ROM ($C100-$CFFF)
io_SETINTCXROM = 0xC007, // E G W Enable Internal ROM ($C100-$CFFF)
io_RDCXROM = 0xC015, // E G R7 Read state of $C100-$CFFF soft switch -- Status of Periph/ROM Access
io_RSTXINT = 0xC015, // C R Reset Mouse X0 Interrupt
io_SETINTC3ROM = 0xC00A, // E G W ROM in Slot 3
io_SETSLOTC3ROM = 0xC00B, // E G W ROM in Aux Slot
io_RDC3ROM = 0xC017, // E G R7 Status of Slot 3/Aux Slot ROM
io_RSTYINT = 0xC017, // C R Reset Mouse Y0 Interrupt
io_MEM_RDRAM_NOWR_2 = 0xC080,
io_MEM_RDROM_WRAM_2 = 0xC081,
io_MEM_RDROM_NOWR_2 = 0xC082,
@ -294,7 +372,10 @@ void resetMemory() {
MEMcfg.WR_RAM = 0;
MEMcfg.RAM_BANK_2 = 0;
MEMcfg.AUX_BANK = 0;
MEMcfg.is80STORE = 0;
// Aux Video Memory
memset( Apple2_VID_AUX, 0xFF | 0x80, sizeof(Apple2_VID_AUX) );
// 64K Main Memory Area
memset( RAM, 0, sizeof(Apple2_64K_RAM) );
// 16K Memory Expansion
@ -329,20 +410,48 @@ INLINE uint8_t ioRead( uint16_t addr ) {
return RAM[io_SPKR];
case io_VID_80col_OFF:
videoMode.col80 = 0;
// case io_VID_CLR80VID:
// videoMode.col80 = 0;
// break;
//
// case io_VID_SET80VID:
// videoMode.col80 = 1;
// break;
//
case io_VID_ALTCHAR:
return videoMode.altChr << 7;
case io_VID_RD80VID:
return videoMode.col80 << 7;
case io_TAPEIN:
return videoMode.page2 << 7;
case io_RDCXROM:
return videoMode.intCxROM << 7;
case io_RDC3ROM:
return videoMode.slotC3ROM << 7;
case io_RD80STORE:
return MEMcfg.is80STORE << 7;
case io_VID_TXTPAGE1:
// printf("io_VID_TXTPAGE1\n");
videoMode.page2 = 0;
if ( MEMcfg.is80STORE ) {
SWITCH_VIDEO_RAM( RAM_PG_RD_TBL, 0x04, Apple2_64K_RAM, 0x04)
SWITCH_VIDEO_RAM( RAM_PG_WR_TBL, 0x04, Apple2_64K_RAM, 0x04)
}
break;
case io_VID_80col_ON:
videoMode.col80 = 1;
break;
case io_VID_AltChar_OFF:
videoMode.altChr = 0;
break;
case io_VID_AltChar_ON:
videoMode.altChr = 1;
case io_VID_TXTPAGE2:
// printf("io_VID_TXTPAGE2\n");
videoMode.page2 = 1;
if ( MEMcfg.is80STORE ) {
SWITCH_VIDEO_RAM( RAM_PG_RD_TBL, 0x04, Apple2_VID_AUX, 0x00)
SWITCH_VIDEO_RAM( RAM_PG_WR_TBL, 0x04, Apple2_VID_AUX, 0x00)
}
break;
case io_VID_Text_OFF:
@ -361,14 +470,6 @@ INLINE uint8_t ioRead( uint16_t addr ) {
videoMode.mixed = 1;
break;
case io_VID_Page2_OFF:
videoMode.page = 0;
break;
case io_VID_Page2_ON:
videoMode.page = 1;
break;
case io_VID_Hires_OFF:
videoMode.hires = 0;
break;
@ -559,15 +660,97 @@ void kbdInput ( uint8_t code ) {
INLINE void ioWrite( uint16_t addr, uint8_t val ) {
// printf("mmio:%04X\n", addr);
// printf("ioWrite:%04X (A:%02X)\n", addr, m6502.A);
switch (addr) {
case io_KBD:
break;
case io_KBDSTRB:
RAM[io_KBD] &= 0x7F;
break;
case io_SETSLOTCXROM:
// printf("io_SETSLOTCXROM\n");
videoMode.intCxROM = 0;
// SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0xC0, Apple2_64K_RAM, 0xC0);
SWITCH_CX_ROM( RAM_PG_RD_TBL, 0xC0, Apple2_64K_RAM, 0xC0);
// RAM_PG_RD_TBL[ 0xC0 ] = DEF_RAM_PAGE(Apple2_64K_RAM, 0xC0);
break;
case io_SETINTCXROM:
// printf("io_SETINTCXROM\n");
videoMode.intCxROM = 1;
// SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0xC0, Apple2_16K_ROM, 0x00);
SWITCH_CX_ROM( RAM_PG_RD_TBL, 0xC0, Apple2_16K_ROM, 0x00);
// RAM_PG_RD_TBL[ 0xC0 ] = DEF_RAM_PAGE(Apple2_16K_ROM, 0x00);
break;
case io_SETSLOTC3ROM:
// printf("io_SETSLOTC3ROM\n");
videoMode.slotC3ROM = 1;
SWITCH_ROM_PAGE( RAM_PG_RD_TBL, 0xC3, Apple2_64K_RAM, 0xC3);
// RAM_PG_RD_TBL[ 0xC3 ] = DEF_RAM_PAGE(Apple2_64K_RAM, 0xC3);
break;
case io_SETINTC3ROM:
// printf("io_SETINTC3ROM\n");
videoMode.slotC3ROM = 0;
SWITCH_ROM_PAGE( RAM_PG_RD_TBL, 0xC3, Apple2_16K_ROM, 0x03);
// RAM_PG_RD_TBL[ 0xC3 ] = DEF_RAM_PAGE(Apple2_16K_ROM, 0x03);
break;
case io_VID_CLR80VID:
// printf("io_VID_CLR80VID\n");
videoMode.col80 = 0;
break;
case io_VID_SET80VID:
videoMode.col80 = 1;
break;
case io_VID_CLRALTCHAR:
videoMode.altChr = 0;
break;
case io_VID_SETALTCHAR:
videoMode.altChr = 1;
break;
case io_80STOREOFF:
// printf("io_80STOREOFF\n");
MEMcfg.is80STORE = 0;
SWITCH_VIDEO_RAM( RAM_PG_RD_TBL, 0x04, Apple2_64K_RAM, 0x04)
SWITCH_VIDEO_RAM( RAM_PG_WR_TBL, 0x04, Apple2_64K_RAM, 0x04)
break;
case io_80STOREON:
// printf("io_80STOREON\n");
MEMcfg.is80STORE = 1;
if ( videoMode.page2 ) {
SWITCH_VIDEO_RAM( RAM_PG_RD_TBL, 0x04, Apple2_VID_AUX, 0x00)
SWITCH_VIDEO_RAM( RAM_PG_WR_TBL, 0x04, Apple2_VID_AUX, 0x00)
}
else {
SWITCH_VIDEO_RAM( RAM_PG_RD_TBL, 0x04, Apple2_64K_RAM, 0x04)
SWITCH_VIDEO_RAM( RAM_PG_WR_TBL, 0x04, Apple2_64K_RAM, 0x04)
}
break;
case io_VID_TXTPAGE1:
// printf("io_VID_TXTPAGE1\n");
videoMode.page2 = 0;
if ( MEMcfg.is80STORE ) {
SWITCH_VIDEO_RAM( RAM_PG_RD_TBL, 0x04, Apple2_64K_RAM, 0x04)
SWITCH_VIDEO_RAM( RAM_PG_WR_TBL, 0x04, Apple2_64K_RAM, 0x04)
}
break;
case io_VID_TXTPAGE2:
// printf("io_VID_TXTPAGE2\n");
videoMode.page2 = 1;
if ( MEMcfg.is80STORE ) {
SWITCH_VIDEO_RAM( RAM_PG_RD_TBL, 0x04, Apple2_VID_AUX, 0x00)
SWITCH_VIDEO_RAM( RAM_PG_WR_TBL, 0x04, Apple2_VID_AUX, 0x00)
}
break;
default:
break;
}