-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPokemon-TCG-Completed-Save-And-Card-Printouts_1_CreateScreenshots.lua
200 lines (163 loc) · 7.58 KB
/
Pokemon-TCG-Completed-Save-And-Card-Printouts_1_CreateScreenshots.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
local screenshotDirectory = "/home/megasaturnv/Pictures/Pokemon-TCG-Completed-Save-And-Card-Printouts_Screenshots/" --Todo: Move to separate config file. Create folder if it doesn't exist. ~ and $HOME do not work here. Need to be an absolute path
function sleepFrames(frames) --Sleep for this number of frames
for i=1,frames do
emu:runFrame()
end
end
function pressAndRelease(key) --Press a key for 1 frame, then release for 1 frame
emu:addKey(key)
sleepFrames(1)
emu:clearKey(key)
sleepFrames(1)
end
function zeroPadTwoDigits(number) --Return a number as a zero-padded 2-digit string
return string.format("%02d", number)
end
function screenshotSelectedCardInList(cardReference, pages)
sleepFrames(20)
for i=1,pages do --Todo: Replace with pressing the A button instead, then checking each screenshot until the page changes back to the list
emu:screenshot(screenshotDirectory .. "/" .. cardReference .. "_" .. tostring(i) .. ".png")
sleepFrames(10)
if i ~= pages then --If we're on the final page, no need to go to the next screen
pressAndRelease(C.GB_KEY.RIGHT) --Press right to see first move
sleepFrames(20)
end
end
end
function screenshotColosseumPack()
pressAndRelease(C.GB_KEY.A) --Enter Colosseum
sleepFrames(20)
pressAndRelease(C.GB_KEY.A) --Enter first card
sleepFrames(20)
for i=1,38 do --38 Pokemon Cards in the Colosseum pack. There are 50 Axx cards in total
screenshotSelectedCardInList("A" .. zeroPadTwoDigits(i), 5) --Pokemon cards usually have 3 to 5 pages, except P19. We will assume 5 pages for this set
pressAndRelease(C.GB_KEY.DOWN) --Go down to the next card
sleepFrames(20)
end
for i=39,50 do --12 Trainer Cards in the Colosseum pack. There are 50 Axx cards in total
screenshotSelectedCardInList("A" .. zeroPadTwoDigits(i), 1) --Trainer cards usually have 1 page, but B45, C48 and D48 have two pages
pressAndRelease(C.GB_KEY.DOWN) --Go down to the next card
sleepFrames(20)
end
for i=1,6 do --6 Energy Cards in the Colosseum pack. There are 7 Exx cards in total (6 in the Colosseum pack)
screenshotSelectedCardInList("E" .. zeroPadTwoDigits(i), 1) --Energy cards have 1 page
pressAndRelease(C.GB_KEY.DOWN) --Go down to the next card
sleepFrames(20)
end
pressAndRelease(C.GB_KEY.B) --Return to Card list
sleepFrames(20)
pressAndRelease(C.GB_KEY.B) --Return to Booster Pack list
sleepFrames(20)
end
function screenshotEvolutionPack()
pressAndRelease(C.GB_KEY.A) --Enter Evolution
sleepFrames(20)
pressAndRelease(C.GB_KEY.A) --Enter first card
sleepFrames(20)
for i=1,42 do --42 Pokemon Cards in the Evolution pack. There are 50 Bxx cards in total
screenshotSelectedCardInList("B" .. zeroPadTwoDigits(i), 5) --Pokemon cards usually have 3 to 5 pages, except P19. We will assume 5 pages for this set
pressAndRelease(C.GB_KEY.DOWN) --Go down to the next card
sleepFrames(20)
end
for i=43,50 do --8 Trainer Cards in the Evolution pack. There are 50 Bxx cards in total
screenshotSelectedCardInList("B" .. zeroPadTwoDigits(i), 2) --Trainer cards usually have 1 page, but B45, C48 and D48 have two pages
pressAndRelease(C.GB_KEY.DOWN) --Go down to the next card
sleepFrames(20)
end
pressAndRelease(C.GB_KEY.B) --Return to Card list
sleepFrames(20)
pressAndRelease(C.GB_KEY.B) --Return to Booster Pack list
sleepFrames(20)
end
function screenshotMysteryPack()
pressAndRelease(C.GB_KEY.A) --Enter Mystery
sleepFrames(20)
pressAndRelease(C.GB_KEY.A) --Enter first card
sleepFrames(20)
for i=1,46 do --46 Pokemon Cards in the Mystery pack. There are 50 Cxx cards in total
screenshotSelectedCardInList("C" .. zeroPadTwoDigits(i), 5) --Pokemon cards usually have 3 to 5 pages, except P19. We will assume 5 pages for this set
pressAndRelease(C.GB_KEY.DOWN) --Go down to the next card
sleepFrames(20)
end
for i=47,50 do --4 Trainer Cards in the Mystery pack. There are 50 Cxx cards in total
screenshotSelectedCardInList("C" .. zeroPadTwoDigits(i), 2) --Trainer cards usually have 1 page, but B45, C48 and D48 have two pages
pressAndRelease(C.GB_KEY.DOWN) --Go down to the next card
sleepFrames(20)
end
screenshotSelectedCardInList("E" .. zeroPadTwoDigits(7), 1) --1 Energy Card in the Mystery pack. There are 7 Exx cards in total (1 in the Mystery pack). Energy cards have 1 page
pressAndRelease(C.GB_KEY.DOWN) --Go down to the next card
sleepFrames(20)
pressAndRelease(C.GB_KEY.B) --Return to Card list
sleepFrames(20)
pressAndRelease(C.GB_KEY.B) --Return to Booster Pack list
sleepFrames(20)
end
function screenshotLaboratoryPack()
pressAndRelease(C.GB_KEY.A) --Enter Laboratory
sleepFrames(20)
pressAndRelease(C.GB_KEY.A) --Enter first card
sleepFrames(20)
for i=1,43 do --43 Pokemon Cards in the Laboratory pack. There are 51 Dxx cards in total
screenshotSelectedCardInList("D" .. zeroPadTwoDigits(i), 5) --Pokemon cards usually have 3 to 5 pages, except P19. We will assume 5 pages for this set
pressAndRelease(C.GB_KEY.DOWN) --Go down to the next card
sleepFrames(20)
end
for i=44,51 do --8 Trainer Cards in the Laboratory pack. There are 51 Dxx cards in total
screenshotSelectedCardInList("D" .. zeroPadTwoDigits(i), 2) --Trainer cards usually have 1 page, but B45, C48 and D48 have two pages
pressAndRelease(C.GB_KEY.DOWN) --Go down to the next card
sleepFrames(20)
end
pressAndRelease(C.GB_KEY.B) --Return to Card list
sleepFrames(20)
pressAndRelease(C.GB_KEY.B) --Return to Booster Pack list
sleepFrames(20)
end
function screenshotPromotionalCardPack()
pressAndRelease(C.GB_KEY.A) --Enter Promotional Card
sleepFrames(20)
pressAndRelease(C.GB_KEY.A) --Enter first card
sleepFrames(20)
for i=1,20 do --18 Pokemon Cards and 2 Trainer cards in the Promotional Card pack. There are 20 Pxx cards in total
screenshotSelectedCardInList("P" .. zeroPadTwoDigits(i), 6) --Pokemon cards usually have 3 to 5 pages, except P19. Trainer cards usually have 1 page. To simplify things, we will assume 6 pages for everything in this set
pressAndRelease(C.GB_KEY.DOWN) --Go down to the next card
sleepFrames(20)
end
pressAndRelease(C.GB_KEY.B) --Return to Card list
sleepFrames(20)
pressAndRelease(C.GB_KEY.B) --Return to Booster Pack list
sleepFrames(20)
end
console:log("\n\n\n\n\n\n\n\nRunning Pokemon-TCG-Completed-Save-And-Printouts.lua")
console:log(emu:getGameTitle()) -- Should be POKECARD. Todo: Check for this
console:log(emu:getGameCode()) -- Should be DMG-AXQE. Todo: Check for this
console:log(tostring(emu:platform())) -- Should be 0. Todo: Possibly check for this, or at least check if different platforms produce the same results or have advantages/disadvantages. For example, the gameboy player may have a border which we don't want
--console:log(emu:checksum()) -- Should be ��S. Todo: Get HEX value for this and check
emu:reset()
sleepFrames(20)
pressAndRelease(C.GB_KEY.A) --Skip intro
sleepFrames(80)
pressAndRelease(C.GB_KEY.A) --Title Screen
sleepFrames(20)
pressAndRelease(C.GB_KEY.A) --Continue From Diary
sleepFrames(40)
pressAndRelease(C.GB_KEY.A) --Turn on the PC
sleepFrames(20)
pressAndRelease(C.GB_KEY.A) --Acknowledge message
sleepFrames(20)
pressAndRelease(C.GB_KEY.A) --Enter "Card Album"
sleepFrames(20)
-- Colosseum Pack
screenshotColosseumPack()
-- Evolution Pack
pressAndRelease(C.GB_KEY.DOWN) --Go down to the next pack
screenshotEvolutionPack()
-- Mystery Pack
pressAndRelease(C.GB_KEY.DOWN) --Go down to the next pack
screenshotMysteryPack()
-- Laboratory Pack
pressAndRelease(C.GB_KEY.DOWN) --Go down to the next pack
screenshotLaboratoryPack()
-- Promotional Card Pack
pressAndRelease(C.GB_KEY.DOWN) --Go down to the next pack
screenshotPromotionalCardPack()
console:log("Finished Pokemon-TCG-Completed-Save-And-Printouts.lua")