added atari5200 support; fixed NES presets

This commit is contained in:
Steven Hugg 2018-06-20 04:06:18 -04:00
parent f784dc743d
commit 59fd2a2945
10 changed files with 445 additions and 10 deletions

4
mame/mameatari400.js Normal file

File diff suppressed because one or more lines are too long

BIN
mame/mameatari400.wasm Normal file

Binary file not shown.

115
presets/atari8-5200/hello.a Normal file
View File

@ -0,0 +1,115 @@
; Atari 5200 "Hello World" sample code
; Written by Daniel Boris (dboris@comcast.net)
;
; Assemble with DASM
;
processor 6502
DMACTL equ $D400 ;DMA Control
sDMACTL equ $07 ;DMA Control Shadow
DLISTL equ $D402 ;Display list lo
DLISTH equ $D403 ;Display list hi
sDLISTL equ $05 ;Display list lo shadow
sDLISTH equ $06 ;Display list hi shadow
CHBASE equ $D409 ;Character set base
CHACTL equ $D401 ;Character control
NMIEN equ $D40E ;NMI Enable
COLOR1 equ $0D ;Color 1 shadow
COLOR2 equ $0E ;Color 2 shadow
org $4000 ;Start of cartridge area
sei ;Disable interrupts
cld ;Clear decimal mode
Start
ldx #$00
lda #$00
crloop1
sta $00,x ;Clear zero page
sta $D400,x ;Clear ANTIC
sta $C000,x ;Clear GTIA
sta $E800,x ;Clear POKEY
dex
bne crloop1
ldy #$00 ;Clear Ram
lda #$02 ;Start at $0200
sta $81
lda #$00
sta $80
crloop2
lda #$00
crloop3
sta ($80),y ;Store data
iny ;Next byte
bne crloop3 ;Branch if not done page
inc $81 ;Next page
lda $81
cmp #$40 ;Check if end of RAM
bne crloop2 ;Branch if not
ldx #$21
dlloop ;Create Display List
lda dlist,x ;Get byte
sta $1000,x ;Copy to RAM
dex ;next byte
bpl dlloop
lda #$03 ;point IRQ vector
sta $200 ;to BIOS routine
lda #$FC
sta $201
lda #$B8 ;point VBI vector
sta $202 ;to BIOS routine
lda #$FC
sta $203
lda #$B2 ;point Deferred VBI
sta $204 ;to BIOS routine
lda #$FC
sta $205
lda #$03
sta CHACTL ;Set Character Control
lda #$84 ;Set color PF2
sta COLOR2
lda #$0F ;Set color PF1
sta COLOR1
lda #$00 ;Set Display list pointer
sta sDLISTL
sta DLISTL
lda #$10
sta sDLISTH
sta DLISTH
lda #$f8 ;Set Charcter Set Base
sta CHBASE
lda #$22 ;Enable DMA
sta sDMACTL
lda #$40 ;Enable NMI
sta NMIEN
print
ldy #$00
cld
prloop
lda text1,y ;Get character
sec
sbc #$20 ;Convert to ATASCII
sta $1800,y ;Store in video memory
iny ;Next character
cpy #11
bne prloop
wait
jmp wait
;Display list data
org $b000
dlist .byte $70,$70,$70,$42,$00,$18,$02,$02,$02,$02,$02,$02,$02
.byte $02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02
.byte $02,$02,$02,$41,$00,$10
;Text data
org $b100
text1 .byte "HELLO WORLD"
org $bffd
.byte $FF ;Don't display Atari logo
.byte $00,$40 ;Start code at $4000

View File

@ -0,0 +1,263 @@
; Atari 5200 "Hello World" sample code
; Written by Daniel Boris (dboris@comcast.net)
;
; Assemble with DASM
;
processor 6502
; ************ Hardware Adresses ***************************
DMACTL equ $D400 ;DMA Control
sDMACTL equ $07 ;DMA Control Shadow
PMBASE equ $D407 ;PM base address
CHBASE equ $D409 ;Character set base
GRACTL equ $C01D ;Graphics control
PRIOR equ $C01B ;PM priorities
SIZEP0 equ $C001 ;Size of player 0
HPOSP0 equ $C000 ;Horizontal position player 0
COLPM0 equ $C012 ;Player 0 color
DLISTL equ $D402 ;Display list lo
DLISTH equ $D403 ;Display list hi
sDLISTL equ $05 ;Display list lo shadow
sDLISTH equ $06 ;Display list hi shadow
CHACTL equ $D401 ;Character control
NMIEN equ $D40E ;NMI Enable
sCOLPM0 equ $08 ;Player/missile 0 color shadow
sCOLPM1 equ $09 ;Player/missile 0 color shadow
sCOLPM2 equ $0A ;Player/missile 0 color shadow
sCOLPM3 equ $0B ;Player/missile 0 color shadow
sCOLOR0 equ $0C ;Color 0 shadow
sCOLOR1 equ $0D ;Color 1 shadow
sCOLOR2 equ $0E ;Color 2 shadow
sCOLOR3 equ $0F ;Color 3 shadow
;*************** Variable ***********************
line equ $20 ;Current DLI line
pm0pos equ $21 ;Current pos of P0
;*************** Start of Code *******************
org $4000 ;Start of cartridge area
Start
sei ;Disable interrupts
cld ;Clear decimal mode
;************** Clear zero page and hardware ******
ldx #$00
lda #$00
crloop1
sta $00,x ;Clear zero page
sta $D400,x ;Clear ANTIC
sta $C000,x ;Clear GTIA
sta $E800,x ;Clear POKEY
dex
bne crloop1
;************* Clear RAM **************************
ldy #$00 ;Clear Ram
lda #$02 ;Start at $0200
sta $81
lda #$00
sta $80
crloop3
lda #$00
sta ($80),y ;Store data
iny ;Next byte
bne crloop3 ;Branch if not done page
inc $81 ;Next page
lda $81
cmp #$40 ;Check if end of RAM
bne crloop3 ;Branch if not
;************* Setup display list *******************
ldx #$21 ;Number of bytes in list
dlloop ;Copy display list to RAM
lda dlist,x ;Get byte
sta $1000,x ;Copy to RAM
dex ;next byte
bpl dlloop
;************ Setup IRQ vectors *********************
lda #$03 ;point IRQ vector
sta $200 ;to BIOS routine
lda #$FC
sta $201
lda #$B8 ;point VBI vector
sta $202 ;to BIOS routine
lda #$FC
sta $203
lda #$B2 ;point Deferred VBI
sta $204 ;to BIOS routine
lda #$FC
sta $205
lda #$00 ;point DLI vector
sta $206 ;to custom routine
lda #$50
sta $207
lda #$00
sta line
;************* Setup hardware registers *************
lda #$22 ;Set color PF0
sta sCOLOR0
lda #$0F ;Set color PF1
sta sCOLOR1
lda #$84 ;Set color PF2
sta sCOLOR2
lda #$00 ;Set Display list pointer
sta sDLISTL
sta DLISTL
lda #$10
sta sDLISTH
sta DLISTH
lda #$f8 ;Set Charcter Set Base
sta CHBASE
lda #$22 ;Enable DMA
sta sDMACTL
lda #$C0 ;Enable NMI + DLI
sta NMIEN
;************ Draw display graphics *******************
ldy #$02 ;Draw bars on screen
lda #$18 ;Screen memory starts at $1800
sta $81
lda #$00
sta $80
ldx #$18
crloop5
lda #$FF ;Bar 4 pixels wide of color 3
sta ($80),y ;Store data
iny
iny ;Skip 4 pixels
lda #$55 ;Bar 4 pixels wide of color 1
sta ($80),y ;Store data
iny
iny ;Skip 4 pixels
lda #$AA ;Bar 4 pixels wide of color 2
sta ($80),y ;Store data
tya
clc
adc #$06 ;Move pointer to next line
tay
dex ;Next line
bne crloop5 ;Branch if not done
;************* Setup Player/Missile registers ***************
lda #$3A ;Enable DMA (single line resolution/
sta sDMACTL ;normal background)
lda #$20 ;Set PM base address ($200)
sta PMBASE
lda #$03 ;Enable players and missiles
sta GRACTL
lda #$16 ;Color of player 0
sta sCOLPM0
ldy #$00
lda #$03 ;Size of player 0
sta SIZEP0
lda #$01 ;Give players priority over playfield
sta PRIOR
;************ Copy player data to RAM ********************************
pmloop1
lda pm1,y ;Get data
sta $2430,y ;Write it into RAM
sta $24C0,y
iny
cpy #$08 ;Copy 8 bytes
bne pmloop1
;************ Move player ********************************************
ldx #$20 ;Starting position of player
mvloop1
jsr waitvb ;Wait for a vertical bank
lda #$00 ;Reset line counter
sta line
stx HPOSP0 ;Set position of player
stx pm0pos ;Save position for DLI
inx
cpx #$B0 ;Check for end of move
bne mvloop1 ;If not keep moving right
lda #$04 ;Give playfield priority player
sta PRIOR
mvloop2
jsr waitvb ;Wait for a vertical blank
lda #$00 ;Reset line counter
sta line
stx HPOSP0 ;Set position of player
stx pm0pos ;Save position for DLI
dex
cpx #$40 ;Check for end of move
bne mvloop2 ;If not keep moving left
lda #$01 ;Give player priority over playfield
sta PRIOR
jmp mvloop1 ;Continue looping
;************ Wait for vertical blank ************************
waitvb
lda $02 ;Read timer (this is incremented during VB)
waitvb2
cmp $02 ;Did it change?
beq waitvb2 ;If not keep waiting
rts
;************ Display list interrupt ************************
org $5000
dli
pha ;Save A
inc line ;Increment the line counter
lda line ;Past the fifth DLI?
cmp #$05
bne done ;If not then exit DLI
lda pm0pos ;Get player 0 position
eor #$FF ;Invert it
sta HPOSP0 ;Set player 0 position
lda #$0F ;Change player color
sta COLPM0 ;
; Note: Player color is changed in hardware register not the shadow
; register so it takes effect immediatly.
done
pla ;Restore A
rti ;Done
;************* Display list data ****************************
org $b000
dlist .byte $70,$70,$70 ;24 blank scanlines
.byte $48,$00,$18 ;Mode 8 and Load memory scan $1800
.byte $88,$88,$88,$88,$88,$88,$88 ;23 more line of mode 8
.byte $88,$88,$88,$88,$88,$88,$88,$88,$88,$88,$88,$88,$88
.byte $88,$88,$88
.byte $41,$00,$10 ;Jump back to start at $1000
;************* Player shape *********************************
pm1 .byte %00111100
.byte %01000010
.byte %10100101
.byte %10000001
.byte %10100101
.byte %10011001
.byte %01000010
.byte %00111100
;************** Cart reset vector **************************
org $bffd
.byte $FF ;Don't display Atari logo
.byte $00,$40 ;Start code at $4000

View File

@ -10,8 +10,8 @@ void main (void) {
// if we've just powered on,
// wait for PPU to warm-up
waitvblank();
waitvblank();
waitvsync();
waitvsync();
// turn off screen
PPU.control = 0x0; // NMI off

View File

@ -22,7 +22,7 @@ byte getchar(byte x, byte y) {
word addr = 0x2020+x+y*32;
byte rd;
// wait for VBLANK to start
waitvblank();
waitvsync();
// set VRAM read address in PPU
PPU.vram.address = addr>>8;
PPU.vram.address = addr&0xff;
@ -37,7 +37,7 @@ byte getchar(byte x, byte y) {
}
void delay(byte count) {
while (count--) waitvblank();
while (count--) waitvsync();
}
////////// GAME DATA
@ -130,10 +130,10 @@ void human_control(Player* p) {
byte joy;
if (!p->human) return;
joy = joy_read (JOY_1);
if (joy & KEY_LEFT) dir = D_LEFT;
if (joy & KEY_RIGHT) dir = D_RIGHT;
if (joy & KEY_UP) dir = D_UP;
if (joy & KEY_DOWN) dir = D_DOWN;
if (joy & JOY_LEFT_MASK) dir = D_LEFT;
if (joy & JOY_RIGHT_MASK) dir = D_RIGHT;
if (joy & JOY_UP_MASK) dir = D_UP;
if (joy & JOY_DOWN_MASK) dir = D_DOWN;
// don't let the player reverse
if (dir < 0x80 && dir != (p->dir ^ 2)) {
p->dir = dir;
@ -230,7 +230,7 @@ AE(1,1,1,1),AE(1,1,1,1),AE(1,1,1,1),AE(1,1,1,1), AE(1,1,1,1),AE(1,1,1,1),AE(1,1,
// put 8x8 grid of palette entries into the PPU
void setup_attrib_table() {
byte index;
waitvblank(); // wait for VBLANK
waitvsync(); // wait for VBLANK
PPU.vram.address = 0x23;
PPU.vram.address = 0xc0;
for( index = 0; index < 0x40; ++index ){

View File

@ -896,6 +896,7 @@ var BaseMAMEPlatform = function() {
var self = this;
var loaded = false;
var preinitted = false;
var romfn;
var romdata;
var video;
@ -1004,6 +1005,7 @@ var BaseMAMEPlatform = function() {
if (opts.preInit) {
opts.preInit(self);
}
preinitted = true;
},
preRun: [
function() {
@ -1069,7 +1071,7 @@ var BaseMAMEPlatform = function() {
this.loadROMFile = function(data) {
romdata = data;
if (romfn) {
if (preinitted && romfn) {
FS.writeFile(romfn, data, {encoding:'binary'});
}
}

43
src/platform/atari8.js Normal file
View File

@ -0,0 +1,43 @@
"use strict";
var Atari8_PRESETS = [
{id:'hello.a', name:'Hello World (ASM)'},
{id:'hellopm.a', name:'Hello Sprites (ASM)'},
];
/// MAME support
var Atari8MAMEPlatform = function(mainElement) {
var self = this;
this.__proto__ = new BaseMAMEPlatform();
//
this.start = function() {
self.startModule(mainElement, {
jsfile:'mameatari400.js',
biosfile:'a5200/5200.rom',
//cfgfile:'atari5200.cfg',
driver:'a5200',
width:280*2,
height:216*2,
romfn:'/emulator/cart.rom',
romsize:0x4000,
preInit:function(_self) {
},
});
}
this.loadROM = function(title, data) {
this.loadROMFile(data);
this.loadRegion(":cartleft:cart:rom", data);
}
this.getPresets = function() { return Atari8_PRESETS; }
this.getToolForFilename = getToolForFilename_6502;
this.getDefaultExtension = function() { return ".c"; };
}
///
PLATFORMS['atari8-5200'] = Atari8MAMEPlatform;

View File

@ -93,6 +93,12 @@ var PLATFORM_PARAMS = {
libargs: ['apple2.lib'],
code_offset: 0x803, // TODO
},
'atari8-5200': {
define: '__APPLE2__',
cfgfile: 'apple2-hgr.cfg',
libargs: ['atari5200.lib'],
//code_offset: 0x803, // TODO
},
'verilog': {
},
};

View File

@ -38,12 +38,14 @@ describe('Worker', function() {
it('should NOT assemble ACME', function(done) {
compile('acme', 'foo: xxx #0\n', 'vcs', done, 0, 0, 2); // TODO
});
/*
it('should compile PLASMA', function(done) {
compile('plasm', 'word x = 0', 'apple2', done, 5, 0);
});
it('should NOT compile PLASMA', function(done) {
compile('plasm', 'word x = ', 'apple2', done, 0, 0, 1);
});
*/
it('should compile CC65', function(done) {
compile('cc65', 'int main() {\nint x=1;\nreturn x+2;\n}', 'nes-conio', done, 40976, 3);
});