Posts for DeHackEd


1 2
7 8 9 32 33
Emulator Coder, Experienced Forum User, Published Author, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
I kinda did the border drawing thing intentionally. I don't remember my exact reasons, but all the drawing functions will error out if you don't draw within the viewing area. If you really want to change behaviour, do this:
do
  local oldbox = gui.drawbox
  function gui.drawbox(x1,y1,x1,y2,colour)
      [ Your code here, use oldbox in place of gui.drawbox]
  end
end
And it's completely compatible with any existing code. As for your ghost, nice going. My basic strategy was two emulators running different scripts, probably using gd to assist. One would locate $PROTAGONIST, take a screen shot, feed it to gd, crop out the excess, and send it to the first emulator which would draw it transparent over where $PROTAGONIST would have been. It requires the gd library and some IPC (interprocess communication) library, probably sockets.
Emulator Coder, Experienced Forum User, Published Author, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
I don't like it. I hate the controls (only one rotate button, and it's where I expect Sonic Drop to be). The eye thing is a nuisance, and changes to the gameplay area have full-screen effects since my eyes are all crossed.
Emulator Coder, Experienced Forum User, Published Author, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
Due to the fact that there are timing issues I neglected to take into account and the fact that the piece sequence I ended up with sucks, this run is being considered a failure. In other news, I'm trying out Master mode now, where the level of abuse is even higher, with low gravity, sonic drop, and an invisible piece credit roll challenge. Now I have a better idea of what I should be doing...
Emulator Coder, Experienced Forum User, Published Author, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
In my "channel", everything should be assumed unassisted unless it says otherwise in the title. Most of those tetris arcade videos are realtime. Only the absurdly fast TA.Death video is tool-assisted.
Emulator Coder, Experienced Forum User, Published Author, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
Problem is this code is meant to be cross-platform. My Linux version must run it successfully. I also draw to an off-screen buffer and blit it to the real screen later due to the one-frame delay (which seems to be consistent with the actual drawing cycle of the snes I think, based on observation with SMetroid.) I plan to keep the current drawing method the same, though some minor changes under the hood. I'm afraid I'm tossing that code in the garbage. On a side note, backing up the old screen image is a good idea. I'm going to do it, because I think you could implement a full GUI overlayed on top of the main control screen by using snes9x.wait() to keep the emulator paused while the user does stuff. I was going to do this to a file/socket so I could enjoy a terminal with game info overlayed, but this seems like fun. As for the cheat search, I just used a copy of gocha's code. I'm pretty sure I didn't modify anything except the File menu and the addition of a new dialog box. I'll see about changing the shortcuts, but I'd dare say the dialogs were screwed up when I found them.
Emulator Coder, Experienced Forum User, Published Author, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
Confirming those as bugs. The good news is that the GUI bug is easy to fix. The bad news as it is right now, the old GUI drawings would remain on screen. I'll have to make some changes to deal with that. As for the joypad input, that makes no sense whatsoever to me... but I'll investigate.
Emulator Coder, Experienced Forum User, Published Author, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
It probably means someone's crawling the site. Lots of connections mean bandwidth lost, a lot of programs being run to generate pages, etc. As for load, it could be some other force is making the CPU/RAM/disk churn. I think the measure of load is "load average" and that could be anything. Edit: Bisqwit was running a peterbox brute force solver that required about 50 gigs of RAM. The server has 6 gigs and the rest goes to swap, this killing all performance. Wow, never thought I'd need to see more than 10 gigs of swap in use.
Emulator Coder, Experienced Forum User, Published Author, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
Actually Upthorn plans Lua in Gens, or I can do it if I get a copy of up-to-date source for the project. (Right bow I'm too tired to be bothered to go looking for it myself)
Emulator Coder, Experienced Forum User, Published Author, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
Yeah, I'll be doing most of my running by hand. The CPU will try to maximize running time by switching between characters to let others recharge. In the field the characters will passively level by whacking stuff en route and otherwise just tightly following me. Currently I'm investigating luck manipulation (there's stuff on around page 12 of this thread) and maybe some battle formulas. About the formulas, iwhere you put a character on the action grid will affect their stats slightly. You can buy yourself a +1 to str or agl and stuff if you take the time to set your actions, even if the CPU never participates in battle. Be interesting to see if it's worth the effort.
Emulator Coder, Experienced Forum User, Published Author, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
For my pre-planning and to assist in writing Lua script(s) to assist, I've been collecting a lot of memory addresses. I've combined them into a simple MediaWiki entry I'm hosting myself. I'm also going to write a bunch of AIs to assist in input handling, and they're loosely documented. Nothing's done yet in terms of recording an SMV; I want to be sufficiently prepared that I have a hope of finishing.
Emulator Coder, Experienced Forum User, Published Author, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
I was considering trying my own at this run as well. Mostly I lack a useful route since I know little about the game. The tool-assisted walkthrough desyncs for me... but I'll figure that out later. I've mapped a fair deal of the useful memory of the game along with a collection of information from various web sites and cheat codes. My intention is to use the Lua engine I wrote to assist in player controls. Writing an AI to control the other players is not entirely out of the question, and automatic luck manipulation would be awesome. Is anybody still working on this, or should I see if a CPU can fight better than a human who's trying to push too many buttons at once? (Joke, but only slightly)
Emulator Coder, Experienced Forum User, Published Author, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
New version time. Highlights:
  • Transparency wasn't quite up to snuff. Colour glitches and the 1-3 range was backwards.
  • Savestate callbacks. Lua can even save data into a savestate to retrieve it at load time.
  • snes9x.wait() allowing you do skip emulation, either to allow the OS a chance to interface with snes9x or just kill time.
Lowlights:
  • GUI transparency requests - selective transparency - remains impossible without using the gd library to do the work for you. The reason is the gui drawing is saved to an off-screen buffer and then copied to the screen later. Per-pixel transparency isn't stored.
Version 0.06
Emulator Coder, Experienced Forum User, Published Author, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
Test version working correctly for savestates. Numbers and string only allowed. Slight changes (mostly irrelevant) to the API. The wait() function remains incomplete. I'll hammer on it tomorrow and probably release a new version unless anyone identifies and complaints.
Emulator Coder, Experienced Forum User, Published Author, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
What does it do wrong? What should it do? Can you give me a program that shows incorrect behaviour? I can not reproduce the problem. gui.transparency(0) works correctly for me.
Emulator Coder, Experienced Forum User, Published Author, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
A lot to reply to. I'll see how much I can cram into one post.
Aqfaq wrote:
Is it possible to make a script that automatically fast-forwards cutscenes, elevators and item pickups in Super Metroid?
while true do -- main loop

   if cutscene_starts_now then
      snes9x.speedmode("turbo")
      while not cutscene_ends_now do
         snes9x.frameadvance()
      end
      snes9x.speedmode("normal")
   end

   -- Other code goes here
   snes9x.frameadvance()
end -- main loop
As for memory addresses, I'll let you figure those out.
DaTeL237 wrote:
As for the second one... simply counting and reporting is very easy, but reverting to the proper value on a state-load is not yet possible i think so there's a new request.... some way of handling events such as (manual) savestate-loading/saving (not sure if there's other interesting events?)
This was the next thing I was thinking of. I've put some concept function descriptions in the savestate section of the API docs. Tell me what you think. I'll put some sample code up later to help clarify.
Dromiceius wrote:
What do you think about a function like Sleep(DWORD milliseconds) to pass CPU time back to the emulator? In other words, to prevent snes9x from going insane when I try something like this:
There was the idea of a snes9x.wait() function and it's loosely documented in the API section as a future development. Basically it would function like snes9x.frameadvance() but not actually do the emulation cycle. You'd give CPU control back to the main loop but it would behave as though you paused for exactly one frame. This should let you do more input using P5 (as you appear to be doing for input) and joypad.read() would give you updated values. As for the practicality, that's something I need to investigate further although I'm fairly optimistic.
Emulator Coder, Experienced Forum User, Published Author, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
Any bug reports or feature requests? I'm listening... *feels sad nobody replies* (4 posts in a row is usually considered bad form, but still)
Emulator Coder, Experienced Forum User, Published Author, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
I've been programming for the better part of 10 years or more. I pretty much taught my high school programming class. When people had problems, they came to ME, not the prof. Making a TAS or two certainly appeals to the aspect of me that enjoys programming and tinkering with machines -- in a way that's what we're doing. Being a programmer really helps with making the dual runs, advanced emulator assistance (one reason I made the Lua SNES9X is so that everybody can gain a little reach into this area) and all that.
Emulator Coder, Experienced Forum User, Published Author, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
Low priority due to severe bugs in the emulator itself, busy life, and the basic fact that I have other projects as well which seem more successful, like that snes9x+lua thing. It's a killjoy, I know.
Emulator Coder, Experienced Forum User, Published Author, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
Last page of thread
Emulator Coder, Experienced Forum User, Published Author, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
Dunno how much is intact in this version, but my Lua version has a command-line option, -autodemo, which will play an SMV on startup. That's in read-only mode. Read-write mode is accessible by pressing Shift+2 (the number 2 above W) and a filename is prompted on your shell.
Emulator Coder, Experienced Forum User, Published Author, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
Just FYI, I've upgraded the smetroid.lua script to include monster hitboxes and HP displays... Since there's currently a new Super Metroid run out, some people might be interested.
Emulator Coder, Experienced Forum User, Published Author, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
Version 0.05 has escaped. The source code was horribly mangled but managed to drag itself to safety.
  • memory.register works for real now. I tried it. I spent an hour or two figuring out how snes9x's memory maps work before giving up and cheating.
  • New gui code, including a user popup option. Even works under linux if you install xmessage
  • More binary manipulation functions
  • snes9x.pause() will pause the emulator (and the script) until the user unpauses
More later.
Emulator Coder, Experienced Forum User, Published Author, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
Done. Anything else? (check around and you'll see what else I've added)
Emulator Coder, Experienced Forum User, Published Author, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
Thanks for the new code. I've tracked it down to a bug in my own code. It's crashing in memory.register itself, isn't it.... I can fix this in a matter of minutes. While I'm at it, is there any suggestion for features that should be added? I have a few minor additions to gui to allow for pop-ups to the user and stuff.... good idea?
Emulator Coder, Experienced Forum User, Published Author, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
While Datel's style of writing function bodies is no different (lua silently rewrites gunty's code to look identical to Datel's during compilation), there's a two problems to be addressed as well. The first is the change to the actual memory.register line. You want to give the function by name, not by actually calling it, which is what you do. The second regards the parameters the function itself gets. No parameter is given to the called function. Lua fills in the name you given with nil to compensate. It may sound stupid, but it's sorta built on the assumption that you'd use a different function for each memory address. Alternatively, you can use upvalues...
-- a "do/end" is a block of scope, just like within a function, while loop, or other indented code block.
do
  local addr = 0x7e0101
  local function registered()
    snes9x.message("Written: "..addr)
  end
  memory.register(addr, registered)
end
Even though "addr" falls out of scope, the function "registered" can still access it, and get its value from there. Every time the flow of code would execute a function() block, a function is actually created out of the local variables in place at the time.

-- We construct 3 "functions" (technically call closures) with identical code,
-- but different upvalues for "addr" in each one. So while it's technically 
-- one function, we can give the illusion that it knows some magic value
-- for its specific invocation
addresses = { 0x7e0001, 0x7e0002, 0x7e0003} -- Just go with it
for key,value in pairs(addresses) do

  -- We need a distinct local for each function
  local addr = value
  local function registered()
     ... -- Use "addr" in here somewhere
  end
  memory.register(addr, registered)
end
... Or should I just add it anyways?
1 2
7 8 9 32 33