-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathwram.asm
3254 lines (2426 loc) · 67.7 KB
/
wram.asm
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
INCLUDE "macros.asm"
INCLUDE "constants.asm"
INCLUDE "vram.asm"
SECTION "WRAM0", WRAM0
UNION
wTempCardCollection:: ; c000
ds $100
NEXTU
wc000:: ; c000
ds $100
NEXTU
; aside from wDecompressionBuffer, which stores the
; de facto final decompressed data after decompression,
; this buffer stores a secondary buffer that is used
; for "lookbacks" when repeating byte sequences.
; actually starts in the middle of the buffer,
; at wDecompressionSecondaryBufferStart, then wraps back up
; to wDecompressionSecondaryBuffer.
; this is used so that $00 can be "looked back", since anything
; before $ef is initialized to 0 when starting decompression.
wDecompressionSecondaryBuffer:: ; c000
ds $ef
wDecompressionSecondaryBufferStart:: ; c0ef
ds $11
NEXTU
; names of the last players who have done
; Card Pop! with current save file
wCardPopNameList:: ; c000
ds CARDPOP_NAME_LIST_SIZE
NEXTU
; buffer used to store a deck that will be built
wDeckToBuild:: ; c000
ds DECK_STRUCT_SIZE
ENDU
ds $100
SECTION "WRAM0 Duels 1", WRAM0
; this union spans from c200 to c3ff
UNION
; In order to be identified during a duel, the 60 cards of each duelist are given an index between 0 and 59.
; These indexes are assigned following the order of the card list in wPlayerDeck or wOpponentDeck,
; which, in turn, follows the internal order of the cards.
; This temporary index of a card identifies the card within the duelist's deck during an ongoing duel.
; Terminology used in labels and comments:
; - The deck index, or the index within the deck of a card refers to the identifier mentioned just above,
; that is, its temporary position in the wPlayerDeck or wOpponentDeck card list during the current duel.
; - The card ID is its actual internal identifier, that is, its number from card_constants.asm.
; check macros/wram.asm for information on each variable
wPlayerDuelVariables:: duel_vars wPlayer ; c200
wOpponentDuelVariables:: duel_vars wOpponent ; c300
NEXTU
; buffer used to store the Card Pop! name list
; that is received from the other player
wOtherPlayerCardPopNameList:: ; c200
ds CARDPOP_NAME_LIST_SIZE
ENDU
UNION
; temporary list of the cards drawn from a booster pack
wBoosterCardsDrawn:: ; c400
wBoosterTempNonEnergiesDrawn:: ; c400
ds $b
wBoosterTempEnergiesDrawn:: ; c40b
ds $b
wBoosterCardsDrawnEnd:: ; c416
ds $6a
NEXTU
wPlayerDeck:: ; c400
ds $80
NEXTU
; lists all the possible candidates of cards
; that can be received through Card Pop!
wCardPopCardCandidates:: ; c400
ds $80
ENDU
wOpponentDeck:: ; c480
ds $80
; this holds names like player's or opponent's.
wNameBuffer:: ; c500
ds NAME_BUFFER_LENGTH
; this holds an $ff-terminated list of card deck indexes (e.g. cards in hand or in bench)
; or (less often) the attack list of a Pokemon card
wDuelTempList:: ; c510
ds $80
UNION
; this is kept updated with some default text that is used
; when the text printing functions are called with text id $0000
wDefaultText:: ; c590
ds $3c
NEXTU
; used in CheckIfCurrentDeckWasChanged to determine whether
; wCurDeckCards was changed from the original
; deck it was based on
wCurDeckCardChanges:: ; c590
ds DECK_SIZE + 1
ENDU
ds $1d
; signals what error, if any, occurred
; during IR communications
; 0 means there was no error
wIRCommunicationErrorCode:: ; c5ea
ds $1
; parameters set for IR communications on own device
; and received from the other device respectively
; these must match for successful communication
wOwnIRCommunicationParams:: ; c5eb
ds $4
wOtherIRCommunicationParams:: ; c5ef
ds $4
; stores the result from LookUpNameInCardPopNameList
; is $ff if name was found in the Card Pop! list
; is $00 otherwise
wCardPopNameSearchResult:: ; c5f3
ds $1
ds $c
SECTION "WRAM0 Text Engine", WRAM0
wc600:: ; c600
ds $100
wc700:: ; c700
ds $100
wc800:: ; c800
ds $100
wc900:: ; c900
ds $100
SECTION "WRAM0 1", WRAM0
wOAM:: ; ca00
ds $a0
; 16-byte buffer to store text, usually a name or a number
; used by TX_RAM1 but not exclusively
wStringBuffer:: ; caa0
ds $10
wcab0:: ; cab0
ds $1
wcab1:: ; cab1
ds $1
wcab2:: ; cab2
ds $1
; initial value of the A register. used to tell the console when reset
wInitialA:: ; cab3
ds $1
; what console we are playing on, either 0 (DMG), 1 (SGB) or 2 (CGB)
; use constants CONSOLE_DMG, CONSOLE_SGB and CONSOLE_CGB for checks
wConsole:: ; cab4
ds $1
; used to select a sprite or a starting sprite from wOAM
wOAMOffset:: ; cab5
ds $1
; FillTileMap fills VRAM0 BG Maps with the tile stored here
wTileMapFill:: ; cab6
ds $1
wIE:: ; cab7
ds $1
; incremented whenever the vblank handler ends. used to wait for it to end,
; or to delay a specific amount of frames
wVBlankCounter:: ; cab8
ds $1
ds $1
; bit0: is in vblank interrupt?
; bit1: is in timer interrupt?
wReentrancyFlag:: ; caba
ds $1
wLCDC:: ; cabb
ds $1
wBGP:: ; cabc
ds $1
wOBP0:: ; cabd
ds $1
wOBP1:: ; cabe
ds $1
; used to request palette(s) to be flushed by FlushPalettes from wBGP, wOBP0, wOBP1,
; wBackgroundPalettesCGB, and/or wBackgroundPalettesCGB to the corresponding hw registers
wFlushPaletteFlags:: ; cabf
ds $1
; set to non-0 to request OAM copy during vblank
wVBlankOAMCopyToggle:: ; cac0
ds $1
; used by HblankWriteByteToBGMap0
wTempByte:: ; cac1
ds $1
; which screen or interface is currently displayed in the screen during a duel
; used to prevent loading graphics or drawing stuff more times than necessary
wDuelDisplayedScreen:: ; cac2
ds $1
; used to increase the play time counter every four timer interrupts (60.24 Hz)
wTimerCounter:: ; cac3
ds $1
wPlayTimeCounterEnable:: ; cac4
ds $1
; byte0: 1/60ths of a second
; byte1: seconds
; byte2: minutes
; byte3: hours (lower byte)
; byte4: hours (upper byte)
wPlayTimeCounter:: ; cac5
ds $5
wRNG1:: ; caca
ds $1
wRNG2:: ; cacb
ds $1
wRNGCounter:: ; cacc
ds $1
; the LCDC status interrupt is always disabled and this always reads as jp $0000
wLCDCFunctionTrampoline:: ; cacd
ds $3
; a jp $nnnn instruction called by the vblank handler. calls a single ret by default
wVBlankFunctionTrampoline:: ; cad0
ds $3
; pointer to a function to be called by DoFrame
wDoFrameFunction:: ; cad3
ds $2
; if non-zero, the game screen can be paused at any time with the select button
wDebugPauseAllowed:: ; cad5
ds $1
; pointer to keep track of where
; in the source data we are while
; running the decompression algorithm
wDecompSourcePosPtr:: ; cad6
ds $2
; number of bits that are still left
; to read from the current command byte
wDecompNumCommandBitsLeft:: ; cad8
ds $1
; command byte from which to read the bits
; to decompress source data
wDecompCommandByte:: ; cad9
ds $1
; if bit 7 is changed from off to on, then
; decompression routine will read next two bytes
; for repeating previous sequence (length, offset)
; if it changes from on to off, then the routine
; will only read one byte, and reuse previous length byte
wDecompRepeatModeToggle:: ; cada
ds $1
; stores in both nybbles the length of the
; sequences to copy in decompression
; the high nybble is used first, then the low nybble
; for a subsequent sequence repetition
wDecompRepeatLengths:: ; cadb
ds $1
wDecompNumBytesToRepeat:: ; cadc
ds $1
wDecompSecondaryBufferPtrHigh:: ; cadd
ds $1
; offset to repeat byte from decompressed data
wDecompRepeatSeqOffset:: ; cade
ds $1
wDecompSecondaryBufferPtrLow:: ; cadf
ds $1
wTempSGBPacket:: ; cae0
ds $10
; temporary CGB palette data buffer to eventually save into BGPD registers.
wBackgroundPalettesCGB:: ; caf0
ds NUM_BACKGROUND_PALETTES palettes
; temporary CGB palette data buffer to eventually save into OBPD registers.
wObjectPalettesCGB:: ; cb30
ds NUM_OBJECT_PALETTES palettes
ds $2
; stores a pointer to a temporary list of elements (e.g. pointer to wDuelTempList)
; to be read or written sequentially
wListPointer:: ; cb72
ds $2
SECTION "WRAM0 Serial Transfer", WRAM0
wSerialOp:: ; cb74
ds $1
wSerialFlags:: ; cb75
ds $1
wSerialCounter:: ; cb76
ds $1
wSerialCounter2:: ; cb77
ds $1
wSerialTimeoutCounter:: ; cb78
ds $1
wcb79:: ; cb79
ds $2
wcb7b:: ; cb7b
ds $2
wSerialSendSave:: ; cb7d
ds $1
wSerialSendBufToggle:: ; cb7e
ds $1
wSerialSendBufIndex:: ; cb7f
ds $1
wcb80:: ; cb80
ds $1
wSerialSendBuf:: ; cb81
ds $20
wSerialLastReadCA:: ; cba1
ds $1
wSerialRecvCounter:: ; cba2
ds $1
wcba3:: ; cba3
ds $1
wSerialRecvIndex:: ; cba4
ds $1
wSerialRecvBuf:: ; cba5
ds $20
wSerialEnd:: ; cbc5
SECTION "WRAM0 Duels 2", WRAM0
ds $1
; In a duel, the main menu current or last selected menu item
; From 0 to 5: Hand, Attack, Check, Pkmn Power, Retreat, Done
wCurrentDuelMenuItem:: ; cbc6
ds $1
; When we're viewing a card's information, the page we are currently at.
; For Pokemon cards, values from $1 to $6 (two pages for attack descriptions)
; For Energy cards, it's always $9
; For Trainer cards, $d or $e (two pages for trainer card descriptions)
; see CARDPAGE_* constants
wCardPageNumber:: ; cbc7
ds $1
; how many selectable items are in a play area screen. used to set wNumMenuItems
; in order to navigate through a play area screen. this becomes the number of bench
; Pokemon cards if wExcludeArenaPokemon is 1, and that number plus 1 if it's 0.
wNumPlayAreaItems:: ; cbc8
ds $1
; selects a PLAY_AREA_* slot in order to display information related to it. used by functions
; such as PrintPlayAreaCardLocation, PrintPlayAreaCardInformation and PrintPlayAreaCardHeader
wCurPlayAreaSlot:: ; cbc9
; X position to display the attached energies, HP bar, and Pluspower/Defender icons
; obviously different for player and opponent side. used by DrawDuelHUD.
wHUDEnergyAndHPBarsX:: ; cbc9
ds $1
; current Y coordinate where some play area information is being printed at. used by functions
; such as PrintPlayAreaCardLocation, PrintPlayAreaCardInformation and PrintPlayAreaCardHeader
wCurPlayAreaY:: ; cbca
; Y position to display the attached energies, HP bar, and Pluspower/Defender icons
; obviously different for player and opponent side. used by DrawDuelHUD.
wHUDEnergyAndHPBarsY:: ; cbca
wPracticeDuelTextY:: ; cbca
ds $1
; selected bench slot (1-5, that is, a PLAY_AREA_BENCH_* constant)
wBenchSelectedPokemon:: ; cbcb
ds $1
; used by CheckIfEnoughEnergiesToRetreat and DisplayRetreatScreen
wEnergyCardsRequiredToRetreat:: ; cbcc
ds $1
wNumRetreatEnergiesSelected:: ; cbcd
ds $1
; used in CheckIfEnoughEnergiesToAttack for the calculation
wAttachedEnergiesAccum:: ; cbce
ds $1
; when you're in a duel submenu like the cards in your hand and you press A,
; the following two addresses keep track of which item was selected by the cursor
wSelectedDuelSubMenuItem:: ; cbcf
ds $1
wSelectedDuelSubMenuScrollOffset:: ; cbd0
ds $1
; CARDPAGETYPE_PLAY_AREA or CARDPAGETYPE_NOT_PLAY_AREA
; some of the elements displayed in a card page change depending on which value
wCardPageType:: ; cbd1
ds $1
; when processing or displaying the play area Pokemon cards of a duelist,
; whether to account for only the benched Pokemon ($01) or also the arena Pokemon ($00).
wExcludeArenaPokemon:: ; cbd2
ds $1
wPlayAreaScreenLoaded:: ; cbd3
ds $1
; determines what to do when player presses the Select button
; while viewing the Play Area:
; - if $0 or $2: no action
; - if $1: menu is accessible where player can examine Hand or other screens
; $2 is reserved for OpenVariousPlayAreaScreens_FromSelectPresses
wPlayAreaSelectAction:: ; cbd4
ds $1
; low byte of the address of the next slot in the hTempRetreatCostCards array to be used
wTempRetreatCostCardsPos:: ; cbd5
ds $1
; in a card list, which keys (among START and A_BUTTON) do not open the item selection
; menu when a card is selected, directly "submitting" the selected card instead.
wNoItemSelectionMenuKeys:: ; cbd6
ds $1
; when viewing a card page, which keys (among B_BUTTON, D_UP, and D_DOWN) will exit the page,
; either to go back to the previous menu or list, or to load the card page of the card above/below it
wCardPageExitKeys:: ; cbd7
ds $1
; used to store function pointer for printing card order
; in card list reordering screen.
wPrintSortNumberInCardListPtr:: ; cbd8
ds $2
; in the hand or discard pile card screen, id of the text printed in the bottom-left box
wCardListInfoBoxText:: ; cbda
ds $2
; in the hand or discard pile card screen, id of the text printed as the header title
wCardListHeaderText:: ; cbdc
ds $2
; when selecting an item of a list of cards which type of menu shows up.
; PLAY_CHECK, SELECT_CHECK, or $00 for none.
wCardListItemSelectionMenuType:: ; cbde
ds $1
; flag indicating whether a list of cards should be sorted by ID
wSortCardListByID:: ; cbdf
ds $1
wEnergyDiscardPlayAreaLocation:: ; cbe0
ds $1
wOpponentTurnEnded:: ; cbe1
ds $1
wOppRNG1:: ; cbe2
ds $1
wOppRNG2:: ; cbe3
ds $1
wOppRNGCounter:: ; cbe4
ds $1
; sp is saved here when starting a duel, in order to save the return address
; however, it only seems to be read after a transmission error in a link duel
wDuelReturnAddress:: ; cbe5
ds $2
; if non-zero, duel menu input is not checked
wDebugSkipDuelMenuInput:: ; cbe7
ds $1
wNumCardsTryingToDraw:: ; cbe8
ds $1
; number of cards being drawn in order to animate the number of cards in
; the hand and in the deck in the draw card screen
wNumCardsBeingDrawn:: ; cbe9
ds $1
ds $3
; temporarily stores 8 bytes for serial send/recv.
; used by SerialSend8Bytes and SerialRecv8Bytes
wTempSerialBuf:: ; cbed
ds $8
ds $2
; return address for when the Link Opponent has
; made a decision on his turn, so that the duel continues
wLinkOpponentTurnReturnAddress:: ; cbf7
ds $2
; when non-0, AIMakeDecision doesn't wait 60 frames and print DuelistIsThinkingText
wSkipDuelistIsThinkingDelay:: ; cbf9
ds $1
wEnergyDiscardMenuDenominator:: ; cbfa
ds $1
wEnergyDiscardMenuNumerator:: ; cbfb
ds $1
; used by TurnDuelistTakePrizes to store the remaining Prizes, so that if more than that
; amount would be taken, only the remaining amount is taken
wTempNumRemainingPrizeCards:: ; cbfc
ds $1
; if FALSE, player is placing initial arena pokemon
; if TRUE, player is placing initial bench pokemon
wPlacingInitialBenchPokemon:: ; cbfd
ds $1
; during a practice duel, identifies an entry of PracticeDuelActionTable
wPracticeDuelAction:: ; cbfe
ds $1
wDuelMainSceneSelectHotkeyAction:: ; cbff
ds $1
wPracticeDuelTurn:: ; cc00
ds $1
; pointer from PracticeDuelTextPointerTable
wPracticeDuelTextPointer:: ; cc01
ds $2
; used to print a Pokemon card's length in feet and inches
wPokemonLengthPrintOffset:: ; cc03
ds $1
; used when opening the card page of an attack when attacking,
; serving as an index for AttackPageDisplayPointerTable.
; see ATTACKPAGE_* constants
wAttackPageNumber:: ; cc04
ds $1
; the value of hWhoseTurn gets loaded here at the beginning of each duelist's turn.
; more reliable than hWhoseTurn, as hWhoseTurn may change temporarily in order to handle status
; conditions or other events of the non-turn duelist. used mostly between turns (to check which
; duelist's turn just finished), or to restore the value of hWhoseTurn at some point.
wWhoseTurn:: ; cc05
ds $1
; number of turns taken by both players
wDuelTurns:: ; cc06
ds $1
; used to signal that the current duel has finished, not to be mistaken with wDuelResult
; 0 = no one has won duel yet
; 1 = player whose turn it is has won the duel
; 2 = player whose turn it is has lost the duel
; 3 = duel ended in a draw (start sudden death match)
wDuelFinished:: ; cc07
ds $1
; current duel is a [wDuelInitialPrizes]-prize match
wDuelInitialPrizes:: ; cc08
ds $1
; a DUELTYPE_* constant. note that for a practice duel, wIsPracticeDuel must also be set to $1
wDuelType:: ; cc09
ds $1
; set to 1 if the coin toss during the CheckSandAttackOrSmokescreenSubstatus check is heads
wGotHeadsFromSandAttackOrSmokescreenCheck:: ; cc0a
ds $1
wAlreadyPlayedEnergy:: ; cc0b
ds $1
; set to TRUE if the confusion check coin toss in AttemptRetreat is tails
wConfusionRetreatCheckWasUnsuccessful:: ; cc0c
ds $1
; DUELIST_TYPE_* of the turn holder
wDuelistType:: ; cc0d
ds $1
; this holds the current opponent's deck minus 2 (that is, a *_DECK_ID constant),
; in order to account for the two unused pointers at the beginning of DeckPointers.
wOpponentDeckID:: ; cc0e
ds $1
wcc0f:: ; cc0f
ds $1
; index (0-1) of the attack or Pokemon Power being used by the player's arena card
; set to $ff when the duel starts and at the end of the opponent's turn
wPlayerAttackingAttackIndex:: ; cc10
ds $1
; deck index of the player's arena card that is attacking or using a Pokemon Power
; set to $ff when the duel starts and at the end of the opponent's turn
wPlayerAttackingCardIndex:: ; cc11
ds $1
; ID of the player's arena card that is attacking or using a Pokemon Power
wPlayerAttackingCardID:: ; cc12
ds $1
wIsPracticeDuel:: ; cc13
ds $1
wNPCDuelistCopy:: ; cc14
ds $1
wOpponentPortrait:: ; cc15
ds $1
; text id of the opponent's name
wOpponentName:: ; cc16
ds $2
; an overworld script starting a duel sets this address to the value to be written into wDuelInitialPrizes
wNPCDuelPrizes:: ; cc18
ds $1
; an overworld script starting a duel sets this address to the value to be written into wOpponentDeckID
wNPCDuelDeckID:: ; cc19
ds $1
; song played during a duel
wDuelTheme:: ; cc1a
ds $1
; holds the energies attached to a given pokemon card. 1 byte for each of the
; 8 energy types (includes the unused one that shares byte with the colorless energy)
wAttachedEnergies:: ; cc1b
ds NUM_TYPES
; holds the total amount of energies attached to a given pokemon card
wTotalAttachedEnergies:: ; cc23
ds $1
; Used as temporary storage for a card's data
wLoadedCard1:: ; cc24
card_data_struct wLoadedCard1
wLoadedCard2:: ; cc65
card_data_struct wLoadedCard2
wLoadedAttack:: ; cca6
atk_data_struct wLoadedAttack
; the damage field of a used attack is loaded here
; doubles as "wAIAverageDamage" when complementing wAIMinDamage and wAIMaxDamage
; little-endian
; second byte may have UNAFFECTED_BY_WEAKNESS_RESISTANCE_F set/unset
wDamage:: ; ccb9
ds $2
; wAIMinDamage and wAIMaxDamage appear to be used for AI scoring
; they are updated with the minimum (or floor) damage of the current attack
; and with the maximum (or ceiling) damage of the current attack
wAIMinDamage:: ; ccbb
ds $1
wAIMaxDamage:: ; ccbc
ds $1
wccbd:: ; ccbd
ds $2
; damage dealt by an attack to a target
wDealtDamage:: ; ccbf
ds $2
; WEAKNESS and RESISTANCE flags for a damaging attack
wDamageEffectiveness:: ; ccc1
ds $1
; used in damage related functions
wTempCardID_ccc2:: ; ccc2
ds $1
wTempTurnDuelistCardID:: ; ccc3
ds $1
wTempNonTurnDuelistCardID:: ; ccc4
ds $1
; the status condition of the defending Pokemon is loaded here after an attack
wccc5:: ; ccc5
ds $1
; *_ATTACK constants for selected attack
; 0 for the first attack (or PKMN Power)
; 1 for the second attack
wSelectedAttack:: ; ccc6
ds $1
; if affected by a no damage or effect substatus, this flag indicates what the cause was
wNoDamageOrEffect:: ; ccc7
ds $1
; used by CountKnockedOutPokemon and TurnDuelistTakePrizes to store the amount
; of prizes to take (equal to the number of Pokemon knocked out)
wNumberPrizeCardsToTake:: ; ccc8
ds $1
; set to TRUE if the coin toss in the confusion check is tails (CheckSelfConfusionDamage)
wConfusionAttackCheckWasUnsuccessful:: ; ccc9
ds $1
; used to store card indices of all stages, in order, of a Play Area Pokémon
wAllStagesIndices:: ; ccca
ds $3
wStatusConditionQueueIndex:: ; cccd
ds $1
; 3-byte array used in effect functions with wStatusConditionQueueIndex as the index,
; used to inflict a variable number of status conditions to Arena Pokemon (max 8)
; byte 1: which duelist side
; byte 2: conditions to remove (e.g. paralysis removes poison condition)
; byte 3: conditions to inflict
wStatusConditionQueue:: ; ccce
ds 3 * 8
; this is 1 (non-0) if dealing damage to self due to confusion
; or a self-destruct type attack
wIsDamageToSelf:: ; cce6
ds $1
wcce7:: ; cce7
ds $1
wDuelFinishParam:: ; cce8
ds $1
; text ID of the name of the deck loaded by CopyDeckData
wDeckName:: ; cce9
ds $2
; a PLAY_AREA_* constant (0: arena card, 1-5: bench card)
wTempPlayAreaLocation_cceb:: ; cceb
ds $1
wccec:: ; ccec
ds $1
; used by the effect functions to return the cause of an effect to fail
; in order print the appropriate text
wEffectFailed:: ; cced
ds $1
wPreEvolutionPokemonCard:: ; ccee
ds $1
; whether Defending Pokemon was forced to switch due to an attack
; determines whether DUELVARS_ARENA_CARD_LAST_TURN_DAMAGE
; gets zeroed or gets updated with wDealtDamage
wDefendingWasForcedToSwitch:: ; ccef
ds $1
; stores the energy cost of the Metronome attack being used.
; it's used to know how many attached Energy cards are being used
; to pay for the attack for damage calculation.
; if equal to 0, then the attack wasn't invoked by Metronome.
wMetronomeEnergyCost:: ; ccf0
ds $1
; effect functions return a status condition constant here when it had no effect
; on the target, in order to print one of the ThereWasNoEffectFrom* texts
wNoEffectFromWhichStatus:: ; ccf1
ds $1
; when non-0, allows the player to skip some delays during a duel by pressing B.
; value read from sSkipDelayAllowed. probably only used for debugging.
wSkipDelayAllowed:: ; ccf2
ds $1
SECTION "WRAM0 2", WRAM0
; on CGB, attributes of the text box borders. (values 0-7 seem to be used, which only affect palette)
; on SGB, colorize text box border with SGB1 if non-0
wTextBoxFrameType:: ; ccf3
ds $1
; pixel data of a tile used for text
; either a combination of two half-width characters or a full-width character
wTextTileBuffer:: ; ccf4
ds TILE_SIZE
wcd04:: ; cd04
ds $1
; used by PlaceNextTextTile
wCurTextTile:: ; cd05
ds $1
; VRAM tile patterns selector for text tiles
; if wTilePatternSelector == $80 and wTilePatternSelectorCorrection == $00 -> select tiles at $8000-$8FFF
; if wTilePatternSelector == $88 and wTilePatternSelectorCorrection == $80 -> select tiles at $8800-$97FF
wTilePatternSelector:: ; cd06
ds $1
; complements wTilePatternSelector by correcting the VRAM tile order when $8800-$97FF is selected
; a value of $80 in wTilePatternSelectorCorrection reflects tiles $00-$7f being located after tiles $80-$ff
wTilePatternSelectorCorrection:: ; cd07
ds $1
; if 0 (DOUBLE_SPACED), text lines are separated by a blank line
; uses constants DOUBLE_SPACED and SINGLE_SPACED
wLineSeparation:: ; cd08
ds $1
; line number in which text is being printed as an offset to
; the topmost line, including separator lines
wCurTextLine:: ; cd09
ds $1
; how to process the current text tile
; 0: full-width font | non-0: half-width font
wFontWidth:: ; cd0a
ds $1
; when printing half-width text, this variable alternates between 0 and the value
; of the first character. 0 signals that no text should be printed in the current
; iteration of Func_235e, while non-0 means to print the character pair
; made of [wHalfWidthPrintState] (first char) and register e (second char).
wHalfWidthPrintState:: ; cd0b
ds $1
; used by CopyTextData
wTextMaxLength:: ; cd0c
ds $1
; half-width font letters become uppercase if non-0, lowercase if 0
wUppercaseHalfWidthLetters:: ; cd0d
ds $1
ds $1
; handles timing of (horizontal or vertical) arrow blinking while waiting for user input.
wCursorBlinkCounter:: ; cd0f
ds $1
wCurMenuItem:: ; cd10
ds $1
wMenuParams:: ; cd11
wMenuCursorXOffset:: ; cd11
ds $1
wMenuCursorYOffset:: ; cd12
ds $1
wMenuYSeparation:: ; cd13
ds $1
wNumMenuItems:: ; cd14
ds $1
wMenuVisibleCursorTile:: ; cd15
ds $1
wMenuInvisibleCursorTile:: ; cd16
ds $1
; if non-NULL, the function loaded here is called once per frame by HandleMenuInput
wMenuUpdateFunc:: ; cd17
ds $2
wMenuParamsEnd::
wListScrollOffset:: ; cd19
ds $1
wListItemXPosition:: ; cd1a
ds $1
wNumListItems:: ; cd1b
ds $1
wListItemNameMaxLength:: ; cd1c
ds $1
; if not NULL, the function loaded here is called once per frame by CardListMenuFunction,
; which is the function loaded to wMenuUpdateFunc for card lists
wListFunctionPointer:: ; cd1d
ds $2
ds $78
; in a card list, the Y position where the <sel_item>/<num_items> indicator is placed
; if wCardListIndicatorYPosition == $ff, no indicator is displayed
wCardListIndicatorYPosition:: ; cd97
ds $1
; x coord of the leftmost item in a horizontal menu
wLeftmostItemCursorX:: ; cd98
ds $1
; used in RefreshMenuCursor_CheckPlaySFX to play a sound during any frame when this address is non-0
wRefreshMenuCursorSFX:: ; cd99
ds $1
; when printing a YES/NO menu, whether the cursor is
; initialized to the YES ($01) or to the NO ($00) item
wDefaultYesOrNo:: ; cd9a
ds $1
; used in _CopyCardNameAndLevel to keep track of the remaining space to copy the text
wCardNameLength:: ; cd9b
ds $1
; stores the total number of coins to flip
wCoinTossTotalNum:: ; cd9c
ds $1
; this stores the result from a coin toss (number of heads)
wCoinTossNumHeads:: ; cd9d
ds $1
; stores type of the duelist that is tossing coins
wCoinTossDuelistType:: ; cd9e