Declare Sub ParseCommandLine()
Declare Sub reset6502()
DECLARE SUB adrmode (ByVal opcode As UByte)
Declare SUB init6502 ()
DECLARE FUNCTION Read6502(BYVAL addr AS UInteger) As UByte
DECLARE SUB Write6502 (BYVAL addr AS UInteger, BYVAL value AS UByte)
DIM SHARED a, x, y, p, s AS UByte 'CPU registers
DIM SHARED pc, savepc as UInteger
Dim Shared totalexec AS ULongInt 'and a couple long ones too
DIM SHARED opcode As UByte
DIM SHARED clockticks, totalticks, execticks AS LongInt
DIM SHARED Ticks(255), instruction(255), addrmode(255), frameskip AS INTEGER
DIM SHARED cpurunning, accuracy, autoskip As UByte
DIM SHARED RAM(65535) AS UByte
Dim Shared PRGMEM(&hFFFFF) As UByte
Dim Shared CHRMEM(&hFFFFF) As UByte
Dim Shared VRAM(&h3FFF) As UByte
Dim Shared VRAMaddr As UInteger
Declare Sub PPUwritereg(ByVal addr As UInteger, ByVal value As UInteger)
Declare Function PPUreadreg(ByVal addr As UInteger) As UByte
Dim Shared keymap1(7) As UShort
Declare Sub SetupKeys()

Type ROMtype
	id As String * 4
	prgcount As UShort
	chrcount As UShort
	flags1 As UByte
	flags2 As UByte
	mirroring As UByte
	mapper As UByte
End Type
Dim Shared ROM As ROMtype
Dim Shared ntmap(3) As UShort

Type PPUtype
	nmivblank As UByte
	vblank As UByte
	sprsize As UByte
	addrinc As UInteger
	nametable As UInteger
	bgcolor As UByte
	colorintensity As UByte
	sprvisible As UByte
	bgvisible As UByte
	sprclip As UByte
	bgclip As UByte
	bgtable As UInteger
	sprtable As UInteger
	disptype As UByte
	spr0hit As UByte
	sprcount As UByte
	vramwrite As UByte
	vscroll As Integer
	hscroll As Integer
	latch As UByte
	scrolllatch As UByte
End Type
Dim Shared PPU As PPUtype
Dim Shared PPUregs(7) As UByte
Dim Shared outputNES(239, 255) As UByte
Dim Shared sprback(255), backgnd(255), sprfront(255) As UInteger
Dim Shared spriteRAM(255), spritebuffer(255), spr0collide As UByte
Dim Shared spriteaddr As UByte
Dim Shared prgbank(31) As UInteger
Dim Shared chrbank(7), curscanline As UInteger

Dim Shared paletteNES(65) As UInteger => {_
   &h808080, &h0000BB, &h3700BF, &h8400A6,_
   &hBB006A, &hB7001E, &hB30000, &h912600,_
   &h7B2B00, &h003E00, &h00480D, &h003C22,_
   &h002F66, &h000000, &h050505, &h050505,_
   &hC8C8C8, &h0059FF, &h443CFF, &hB733CC,_
   &hFF33AA, &hFF375E, &hFF371A, &hD54B00,_
   &hC46200, &h3C7B00, &h1E8415, &h009566,_
   &h0084C4, &h111111, &h090909, &h090909,_
   &hFFFFFF, &h0095FF, &h6F84FF, &hD56FFF,_
   &hFF77CC, &hFF6F99, &hFF7B59, &hFF915F,_
   &hFFA233, &hA6BF00, &h51D96A, &h4DD5AE,_
   &h00D9FF, &h666666, &h0D0D0D, &h0D0D0D,_
   &hFFFFFF, &h84BFFF, &hBBBBFF, &hD0BBFF,_
   &hFFBFEA, &hFFBFCC, &hFFC4B7, &hFFCCAE,_
   &hFFD9A2, &hCCE199, &hAEEEB7, &hAAF7EE,_
   &hB3EEFF, &hDDDDDD, &h111111, &h111111, &h000000, &hFFFFFF} 'the last two i added for my DrawText routine

Dim Shared joypad1(7), curbuttonjoy1, dosetkeys As UByte
Dim Shared text As String
