Language:
Lua     Change language:
Pastebin: 93187
Author: Dammit
Subject: FCEU emulator info display for Snake's Revenge game
Created: 2008-08-06 02:17:09
Download and save
Toggle line numbers
1--lua script for fceu 0.98-28 (and later) 
2--purpose: display enemy HP, bomb timers, and hostage count for Snake's Revenge NES game 
3--written by Dammit 7/24/2008; last edited 8/4/2008 
4 
5ynudge = 24 
6xnudge = 8 
7gui.transparency(1
8 
9while true do 
10 
11-- define hostage properties 
12rescues = memory.readbyte(0x6e
13hostage = memory.readbyte(0x438
14 
15-- define bomb properties 
16sidescrl = memory.readbyte(0x40
17bomblaid = memory.readbyte(0x42d
18bombxpos = memory.readbyte(0x485
19bombypos = memory.readbyte(0x46f
20bombtime = memory.readbyte(0x574
21 
22-- define the enemy coordinates 
23e1ypos = memory.readbyte(0x47a
24e2ypos = memory.readbyte(0x47b
25e3ypos = memory.readbyte(0x47c
26e4ypos = memory.readbyte(0x47d
27e5ypos = memory.readbyte(0x47e
28 
29e1xpos = memory.readbyte(0x490
30e2xpos = memory.readbyte(0x491
31e3xpos = memory.readbyte(0x492
32e4xpos = memory.readbyte(0x493
33e5xpos = memory.readbyte(0x494
34 
35-- offset the drawn text, but only if it will stay in bounds 
36if e1ypos>=ynudge then e1ypos = e1ypos-ynudge end 
37if e2ypos>=ynudge then e2ypos = e2ypos-ynudge end 
38if e3ypos>=ynudge then e3ypos = e3ypos-ynudge end 
39if e4ypos>=ynudge then e4ypos = e4ypos-ynudge end 
40if e5ypos>=ynudge then e5ypos = e5ypos-ynudge end 
41 
42if e1xpos>=xnudge then e1xpos = e1xpos-xnudge end 
43if e2xpos>=xnudge then e2xpos = e2xpos-xnudge end 
44if e3xpos>=xnudge then e3xpos = e3xpos-xnudge end 
45if e4xpos>=xnudge then e4xpos = e4xpos-xnudge end 
46if e5xpos>=xnudge then e5xpos = e5xpos-xnudge end 
47 
48-- define enemy HP 
49e1hp = memory.readbyte(0x5cd
50e2hp = memory.readbyte(0x5ce
51e3hp = memory.readbyte(0x5cf
52e4hp = memory.readbyte(0x5d0
53e5hp = memory.readbyte(0x5d1
54 
55-- checks if the enemy is alive 
56e1alive = memory.readbyte(0x40c
57e2alive = memory.readbyte(0x40d
58e3alive = memory.readbyte(0x40e
59e4alive = memory.readbyte(0x40f
60e5alive = memory.readbyte(0x410
61 
62nocontrol = memory.readbyte(0x36
63 
64local function drawdata() 
65 
66--for some reason, at least one thing (like this pixel) must be drawn every frame 
67gui.drawpixel(0,0,"black"
68 
69-- draw HP only during the action 
70if nocontrol==0 then 
71 
72if hostage==204 or hostage==222 then 
73gui.text(e1xpos-24,e1ypos,"HOSTAGES:"
74gui.text(e1xpos+22,e1ypos,rescues) 
75end 
76 
77-- draw bomb time only if there's a bomb 
78if sidescrl==0 and bomblaid==14 then gui.text(bombxpos,bombypos,bombtime) end 
79if sidescrl==2 and bomblaid==8 then gui.text(bombxpos,bombypos,bombtime) end 
80 
81-- draw HP only if the enemy is alive 
82if e1alive~=0 and e1hp>0 then gui.text(e1xpos,e1ypos,e1hp) end 
83if e2alive~=0 and e2hp>0 then gui.text(e2xpos,e2ypos,e2hp) end 
84if e3alive~=0 and e3hp>0 then gui.text(e3xpos,e3ypos,e3hp) end 
85if e4alive~=0 and e4hp>0 then gui.text(e4xpos,e4ypos,e4hp) end 
86if e5alive~=0 and e5hp>0 then gui.text(e5xpos,e5ypos,e5hp) end 
87 
88end 
89 
90end 
91 
92gui.register(drawdata) 
93   FCEU.frameadvance() 
94end 
Download and save
Toggle line numbers
Thread:
Tip: Click the line numbers to toggle highliting on that line.

Paste followup:

Language:
Author:
Subject:


    Tabstop:     bigger biggest
Note: You can prefix a line with "@@@" to highlight it.