1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-12-09 19:49:18 +00:00

apple2: can read from boot prom

This commit is contained in:
Steven Hugg 2020-07-05 12:36:41 -05:00
parent a815b18d7d
commit 0131ed15f3
4 changed files with 89 additions and 21 deletions

View File

@ -436,3 +436,51 @@ https://bellard.org/tcc/
https://wiki.osdev.org/Smaller_C
https://yasm.tortall.net/
https://wiki.osdev.org/Tool_Comparison
COMPONENT EMULATION
Emulate discrete chips
- verilog
- js
- wasm? (overhead?)
Block diagram level
Buses
Insn/cycle timing
Pos/neg clock edge
Timers
Polling vs. callbacks (https://github.com/floooh/chips)
- callbacks might only affect devices internally, until next cycle
CRT simulator
Move leaf nodes to workers (sound chips)
CPU opcode-step switch: https://floooh.github.io/2019/12/13/cycle-stepped-6502.html
- macros are cool!
Inspect bus edges and internal state
type Bits<N> = number;
interface Clocked { }
interface BusListener<N> {
recv(value : Bits<N>) : void;
}
class Bus<N> {
listeners : BusListener<N>;
send(value : Bits<N>) : void {
}
}
function bus(bits : number) {
return function(
target: any,
propertyKey: string,
descriptor: PropertyDescriptor
) {
//descriptor.configurable = value;
};
}
class M6502_T {
IR : Bits<16>; /* internal instruction register */
addr : Bus<16>;
data : Bus<8>;
@bus(16) address : Bus<16>;
}

11
scripts/dist.sh Executable file
View File

@ -0,0 +1,11 @@
# https://github.com/Kentzo/git-archive-all
# build archives
export VERSION=`git tag | tail -1`
export OUTDIR=dist
echo Creating $OUTDIR
git-archive-all --prefix . release/$OUTDIR.zip
zip -9r release/$OUTDIR.zip gen
mkdir $OUTDIR
cd $OUTDIR
unzip ../release/$OUTDIR.zip

View File

@ -2,5 +2,5 @@
. ./scripts/env.sh
DESTPATH=$RSYNC_PATH/dev/
git ls-files -z | rsync --stats --exclude '.*' --exclude 'scripts/*' --exclude=node_modules -ril --chmod=a+rx -e "ssh" --files-from - -0 . $DESTPATH
rsync --stats -rpilvz --chmod=a+rx -e "ssh" ./gen config.js $DESTPATH/
git ls-files -z | rsync --stats -riltz --exclude '.*' --exclude 'scripts/*' --exclude=node_modules --chmod=a+rx -e "ssh" --files-from - -0 . $DESTPATH
rsync --stats -riltz --chmod=a+rx -e "ssh" ./gen config.js $DESTPATH/

View File

@ -28,7 +28,7 @@ interface AppleIIControlsState {
interface AppleIIState extends AppleIIStateBase, AppleIIControlsState {
c : MOS6502State;
grswitch : number;
slots: any[];
slots: SlotDevice[];
}
interface SlotDevice extends Bus {
@ -147,30 +147,40 @@ export class AppleII extends BasicScanlineMachine {
this.auxRAMselected = false;
this.auxRAMbank = 1;
this.writeinhibit = true;
this.skipboot();
}
skipboot() {
// execute until $c600 boot
for (var i=0; i<2000000; i++) {
this.cpu.advanceClock();
if (this.cpu.getPC() == 0xc602) {
break;
}
if ((this.cpu.getPC()>>8) == 0xc6) break;
}
// get out of $c600 boot
for (var i=0; i<2000000; i++) {
this.cpu.advanceClock();
if ((this.cpu.getPC()>>8) < 0xc6) break;
}
}
noise() : number {
return (this.rnd = xorshift32(this.rnd)) & 0xff;
}
readConst(address:number) : number {
if (address < 0xc000) {
return this.ram[address];
} else if (address >= 0xd000) {
if (!this.auxRAMselected)
return this.bios[address - 0xd000];
else if (address >= 0xe000)
return this.ram[address];
else
return this.ram[address + this.bank2rdoffset];
} else
return 0;
}
readConst(address: number): number {
if (address < 0xc000) {
return this.ram[address];
} else if (address >= 0xd000) {
if (!this.auxRAMselected)
return this.bios[address - 0xd000];
else if (address >= 0xe000)
return this.ram[address];
else
return this.ram[address + this.bank2rdoffset];
} else if (address >= 0xc100 && address < 0xc800) {
var slot = (address >> 8) & 7;
return (this.slots[slot] && this.slots[slot].readROM(address & 0xff)) | 0;
} else {
return 0;
}
}
read(address:number) : number {
address &= 0xffff;
if (address < 0xc000 || address >= 0xd000) {
@ -221,8 +231,7 @@ export class AppleII extends BasicScanlineMachine {
return (this.slots[slot-8] && this.slots[slot-8].read(address & 0xf)) | 0;
}
} else if (address >= 0xc100 && address < 0xc800) {
var slot = (address >> 8) & 7;
return (this.slots[slot] && this.slots[slot].readROM(address & 0xff)) | 0;
return this.readConst(address);
}
return this.noise();
}