Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/Assets/Lua/NES/PunchOutStats.lua
2 views
1
--Mike Tyson's Punch Out!!
2
--Shows Oppoenent & Mac's Health and damage amounts.
3
--adelikat
4
5
6
local EHP = 0x0398 -- Enemy HP address
7
local EHPx= 178
8
local EHPy= 14
9
local EnemyHP = 0
10
local lastEHP = 0
11
12
local MHP = 0x0391 -- Mac HP address
13
local MHPx = 122
14
local MHPy = 14
15
local MacHP = 0
16
local lastMHP = 0
17
18
local OppKnockedDown = 0x0005 -- Oppoenent is on the canvas flag
19
local OppDown -- Stores contents of 0x0005
20
local OppDx = 130
21
local OppDy = 70
22
local OppWillGetUpWith = 0x039E -- Health that the oppoenent will get up with
23
local OppWillGet -- Stores contents of 0x039E
24
25
local OppHitFlag = 0x03E0
26
local OppHit
27
local OppHitTimer = 0
28
local OppHitToDisplay = 0
29
30
local OppGetUpCountAddr = 0x00C4
31
local OppGetUpCount = 0
32
local OppGetUpX = 0
33
local OppGetUpY = 24
34
35
OHitValuex = 100
36
OHitValuey = 100
37
38
--*****************************************************************************
39
function IsOppDown()
40
--*****************************************************************************
41
OppDown = mainmemory.read_u8(OppKnockedDown)
42
if OppDown > 0 then
43
return true
44
end
45
return false
46
end
47
48
--*****************************************************************************
49
function OppIsHit()
50
--*****************************************************************************
51
OppHit = mainmemory.read_u8(OppHitFlag)
52
if OppHit > 0 then
53
return true
54
end
55
return false
56
end
57
58
59
60
--*****************************************************************************
61
while true do
62
--*****************************************************************************
63
EnemyHP = mainmemory.read_u8(EHP)
64
gui.text(0,0,"Opponent: " .. EnemyHP, null, null, "topright")
65
66
MacHP = mainmemory.read_u8(MHP)
67
gui.text(0,12,"Mac: " .. MacHP, null, null, "topright")
68
69
if IsOppDown() then
70
OppWillGet = mainmemory.read_u8(OppWillGetUpWith)
71
OppGetUpCount = (mainmemory.read_u8(OppGetUpCountAddr) - 153)
72
if OppGetUpCount == -153 then
73
OppGetUpCount = "never!"
74
end
75
gui.text(0, 12, "Next health: " .. OppWillGet, null, null, "bottomright")
76
gui.text(OppGetUpX, OppGetUpY, "Will get up on: " .. OppGetUpCount, null, null, "bottomright")
77
end
78
79
if OppIsHit() then
80
OppHitToDisplay = lastEHP - EnemyHP
81
OppHitTimer = 60
82
83
end
84
85
if OppHitTimer > 0 then
86
gui.text(0, 0, "Damage: " .. OppHitToDisplay, null, null, "bottomright")
87
end
88
89
90
if OppHitTimer > 0 then
91
OppHitTimer = OppHitTimer - 1
92
end
93
94
emu.frameadvance()
95
lastEHP = EnemyHP
96
lastMHP = MacHP
97
end
98
99