It is currently Mon Nov 20, 2017 5:53 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Fri Aug 25, 2017 5:17 pm 
Offline

Joined: Sun Feb 07, 2016 6:16 pm
Posts: 299
Got most of it working now - just a matter of implementing the API at this point.
Here's what it looks like in the UI. It's possible to have multiple script windows open, each running in their own independent "sandbox".
Attachment:
scriptwindow.png
scriptwindow.png [ 63.54 KiB | Viewed 302 times ]

For the API, so far I've got this roughly planned:
Code:
//read/write have side-effects, debugRead/debugWrite have none.
//Allows you to read all kinds of memory (cpu, ppu, chr rom/ram, prg rom/ram, oam, etc.)
emu.read(address, type): int
emu.write(address, value, type): void
emu.debugRead(address, type): int
emu.debugWrite(address, value, type): void

//The "state" object should contain most of what is important about the emulator's state
//CPU, PPU, APU & Cartridge
emu.getState(): table
emu.setState(state: table): void

//Callbacks for read/write/exec and events like nmi, irq, reset, start of frame, end of frame
//The bulk of a script's code will need to be in these callbacks
emu.addMemoryCallback(func, type, start, end): void
emu.removeMemoryCallback(func, type, start, end): void
emu.addEventCallback(func, eventtype): void
emu.removeEventCallback(func, eventtype): void

//Drawing-related
emu.drawString(x, y, string, color, frameCount): void
emu.drawLine(x, y, x2, y2, color, frameCount): void
emu.drawRectangle(x, y, width, height, color, fill, frameCount): void
emu.getPixel(x, y): int
emu.setPixel(x, y, color): void
emu.getMousePosition(): table [x, y]

//Logging
emu.log(message: string): void  //Log to LUA-specific console
emu.displayMessage(message: string): void  //Print via OSD

//Cheats
emu.addCheatCode(cheat: string, type: enum): void
emu.clearCheatCodes(): void

//Input
emu.getInput(port: int): table [a,b,start,select,up,down,left,right]
emu.setInput(port: int, state: table, durationInFrames: int): void

//Controlling the emulation
emu.reset(hardReset: bool): void
emu.break(): void
emu.resume(): void
emu.execute(cycleCount: int, type: int): void
emu.rewind(seconds: int): void

//Screenshots, savestates
emu.takeScreenshot(): string (png)
emu.saveSavestate(): string
emu.loadSavestate(state: string): void

Some stuff is definitely missing, but I think it's a decent start. If you see anything critical missing, or something terribly bad, let me know.


Top
 Profile  
 
PostPosted: Fri Aug 25, 2017 7:11 pm 
Offline
User avatar

Joined: Mon Dec 07, 2009 11:08 am
Posts: 79
Location: USA
I am excited for this, thx for your work Sour!


Top
 Profile  
 
PostPosted: Sun Aug 27, 2017 3:32 pm 
Offline

Joined: Sun Feb 07, 2016 6:16 pm
Posts: 299
Almost finished implementing the API - pretty much everything except setState/setInput is done.
As a test, I decided to try porting feos' SoundDisplay2.lua script from FCEUX and it pretty much works:
Attachment:
sounddisplay2.png
sounddisplay2.png [ 81.8 KiB | Viewed 232 times ]
I used the exact same font/draw logic as FCEUX for the drawString function, so it makes it easier to port something like this over.


Top
 Profile  
 
PostPosted: Sun Aug 27, 2017 6:00 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19237
Location: NE Indiana, USA (NTSC)
Sour wrote:
I used the exact same font/draw logic as FCEUX for the drawString function, so it makes it easier to port something like this over.

In "Triangle", the raised "g" looks distracting. Would it be worth sacrificing one pixel of the capital letters' height to make the descenders look less off-kilter?


Attachments:
BaseSeven_vx8.png
BaseSeven_vx8.png [ 1.12 KiB | Viewed 209 times ]
Top
 Profile  
 
PostPosted: Sun Aug 27, 2017 6:59 pm 
Offline

Joined: Sun Feb 07, 2016 6:16 pm
Posts: 299
Good point - since I'm not actually restricted by a grid, I cheated and added some code to manually offset some of the characters.
Moved down g/y/p/q & increased the height of the p/q characters (the bottom part seemed too short otherwise)
The background color isn't shifted since that would look odd in most scenarios.
Attachment:
font.png
font.png [ 3.09 KiB | Viewed 200 times ]


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2

All times are UTC - 7 hours


Who is online

Users browsing this forum: Google Adsense [Bot], zeroone and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group