diff --git a/SOURCE/lugiaevent/00-C000.asm b/SOURCE/lugiaevent/00-C000.asm new file mode 100644 index 0000000..9b81c7e --- /dev/null +++ b/SOURCE/lugiaevent/00-C000.asm @@ -0,0 +1,174 @@ +INCLUDE "../macros.asm" +SECTION "eonticket",ROM0[$100] +jp Start +db $00 + +TicketSprite: ; 104 + INCBIN "lugia.bin" +TicketPalette: ; 1604 + INCBIN "lugiapal.bin" + +Prologue: + INCBIN "prologue-{REGION_NAME}.bin" + +DataPacket: ; 164a + INCBIN "eonticket-{REGION_NAME}.mev" + db 0,0,0 ; padding + +INCLUDE "../common/mem_struct.asm" + +SpriteData: + dw TicketSprite,TicketPalette + db $7,$7,$01,$01,$01,$01,$01 ; width 15, height 8 + +Instructions1: ; 1921 + db "Link e-Reader to Pokémon Ruby or \n" + db "Sapphire and select MYSTERY EVENTS\n" + db "on the game's main menu.\n" + db "Press the B Button to cancel.\0" + +Instructions2: ; 199d + db "Press the A Button on the Game Boy\n" + db "Advance containing Pokémon Ruby or\n" + db "Sapphire to begin sending the\n" + db "LUGIA EVENT.\0" + +DeliveryInProcess: ; 1a0d + db "LUGIA EVENT delivery in Progress...\0" + +TicketDelivered: ; 1a2f + db "LUGIA EVENT delivered!\n" + db "\n" + db "Press the A Button to resend.\n" + db "Press the B Button to cancel.\0" + +; this function is subtly different than the one +; on the Battle e cards, for no apparent reason +TransferData: + LD_IND_HL SomeVar1 + push de + ld hl, $bbbb + LD_IND_HL Space_1 + EX_DE_HL + LD_IND_HL Space_2 + API_0C7 Space_1 + + wait $01 + pop hl + inc hl + ld b, $01 + call WordShiftRight + + LD_IND_HL SomeVar2 +.asm_1aa1 + LD_HL_IND SomeVar2 + ld a, l + or h + ret z + + ld hl, $8888 + LD_IND_HL Space_1 + ld e, $01 + +.asm_1aaf + ld a, e + cp $08 + jr nc, .asm_1ad9 + + push de + LD_HL_IND SomeVar1 + ld c, [hl] + inc hl + ld b, [hl] + inc hl + LD_IND_HL SomeVar1 + ld l, e + ld h, $00 + add hl, hl + ld de, Space_1 + add hl, de + ld [hl], c + inc hl + ld [hl], b + pop de + LD_HL_IND SomeVar2 + dec hl + LD_IND_HL SomeVar2 + ld a, l + or h + jr z, .asm_1ad9 + + inc e + jr .asm_1aaf + +.asm_1ad9 + API_0C7 Space_1 + wait $01 + jr .asm_1aa1 + +Start: ; 1ae2 + API_121 + + CreateCustomSprite SpriteHandlePtr, $80, SpriteData + SetSpritePos SpriteHandlePtr, 120, 64 + SpriteHide SpriteHandlePtr + + CreateRegion RegionHandlePtr, 30, 6, 0, 14, 0, 4 + + ld h, a + ld l, $00 + SetTextSize + + API_09B RegionHandlePtr, $0102 + SetTextColor RegionHandlePtr, 2, 0 + SetRegionColor RegionHandlePtr, 0 + SetBackgroundPalette 16, $0040, TicketPalette + + FadeIn 16 + wait 16 + + API $0C6 + + DrawText RegionHandlePtr, Instructions1, 8, 4 + API $08D + +INCLUDE "../common/wait_for_link.asm" + + SpriteShow SpriteHandlePtr + + DrawText RegionHandlePtr, Instructions2, 8, 4 + API $08D + + ld a, b + nop + +UNKNOWN_VALUE EQU $0078 +INCLUDE "../common/wait_for_ready.asm" + + DrawText RegionHandlePtr, DeliveryInProcess, 8, 4 + +DATA_TRANSFER_LENGTH EQU 6144 +INCLUDE "../common/transfer_data.asm" + ld hl, $5fff + LD_IND_HL Space_1 + API_0C7 Space_1 + + wait $80 + + SpriteHide SpriteHandlePtr + + DrawText RegionHandlePtr, TicketDelivered, 8, 4 + + API $08D + ld c, a + nop + +INCLUDE "../common/wrap_up.asm" + +INCLUDE "../common/word_shift_right.asm" + +SomeVar1: ; 1CA2 + db $FF,0 ; mark EOF +RegionHandlePtr: db 0 ; 1CA4 +SpriteHandlePtr: db 0,0 ; 1CA5 +SomeVar2: db 0,0 ; 1CA7 \ No newline at end of file diff --git a/SOURCE/lugiaevent/00-C000.raw b/SOURCE/lugiaevent/00-C000.raw new file mode 100644 index 0000000..eb53c43 Binary files /dev/null and b/SOURCE/lugiaevent/00-C000.raw differ diff --git a/SOURCE/lugiaevent/Makefile b/SOURCE/lugiaevent/Makefile new file mode 100644 index 0000000..11d6e49 --- /dev/null +++ b/SOURCE/lugiaevent/Makefile @@ -0,0 +1,40 @@ +all: 00-C000-EN.raw verify +verify: + md5sum --check eonticket.md5 + + +eonticket-%.tx: eonticket.asm + python ../scripts/regionalize.py $< $@ $* $* +eonticket-%.o: eonticket-%.tx + ./rgbasm -o $@ $< +eonticket-%.gbc: eonticket-%.o + ./rgblink -o $@ $< +eonticket-%.bin: eonticket-%.gbc + python ../scripts/stripgbc.py $< $@ +eonticket-%.mev: eonticket-%.bin + python ../scripts/checksum.py $< $@ + +prologue-%.tx: prologue.asm + python ../scripts/regionalize.py $< $@ $* $* +prologue-%.o: prologue-%.tx + ./rgbasm -o $@ $< +prologue-%.gbc: prologue-%.o + ./rgblink -o $@ $< +prologue-%.bin: prologue-%.gbc + python ../scripts/stripgbc.py $< $@ + +00-C000-%.tx: 00-C000.asm eonticket-%.mev prologue-%.bin + python ../scripts/ereadertext.py $< $@ $* +00-C000-%.o: 00-C000-%.tx + ./rgbasm -o $@ $< +00-C000-%.gbc: 00-C000-%.o + ./rgblink -o $@ $< +00-C000-%.z80: 00-C000-%.gbc + python ../scripts/stripgbc.py $< $@ +00-C000-%.vpk: 00-C000-%.z80 + ./nevpk -c -i $< -o $@ +00-C000-%.raw: 00-C000-%.vpk + ./nedcmake -i $< -o $@ -type 1 -region 1 + +clean: + rm -f *.tx *.o *.gbc *.z80 *.bin *.mev *.vpk *.raw \ No newline at end of file diff --git a/SOURCE/lugiaevent/eonticket.asm b/SOURCE/lugiaevent/eonticket.asm new file mode 100644 index 0000000..d0e87e6 --- /dev/null +++ b/SOURCE/lugiaevent/eonticket.asm @@ -0,0 +1,196 @@ +INCLUDE "../macros.asm" +INCLUDE "../constants/items.asm" +INCLUDE "../constants/scriptcommandslugia.asm" + + Mystery_Event + + db CHECKSUM_CRC + dd 0 ; checksum placeholder + GBAPTR DataStart + GBAPTR DataEnd + +DataStart: + db IN_GAME_SCRIPT + db 24,66 ; Abandoned Ship + db 4 ; item in bottom right room + GBAPTR NormanScriptStart + GBAPTR NormanScriptEnd + + + + db MIX_RECORDS_ITEM + db 1 ; ??? +IF REGION == REGION_DE + db 5 ; distribution limit from German debug ROM +ELSE + db 30 ; distribution limit from English release +ENDC + dw EON_TICKET + + + + db PRELOAD_SCRIPT + GBAPTR PreloadScriptStart + + db END_OF_CHUNKS + + +GoSeeYourFather: + Text_DE "Lauf und besuche deinen Vater in der\n" + Text_DE "ARENA von BLÜTENBURG CITY.@" + + Text_EN "The ABANDONED SHIP has been rumbling.\n" + Text_EN "A powerful Pokémon has moved in.@" + + + +NormanScriptStart: + setvirtualaddress NormanScriptStart + + checkitemroom TM04, 1 + + compare LASTRESULT, 0 + + virtualgotoif 1, NoRoomToGive + + + + + setwildbattle $F9, $46, $0061 + + copyvarifnotzero $8000, TM04 + + copyvarifnotzero $8001, 1 + + checkitemtype $0004 + + callstd 1 + + closeonkeypress + + fadeout $3 + + playmoncry $F9, $0 + + virtualmsgbox Lugia + + waitmsg + + waitkeypress + + release + + waitmoncry + + setvar $8004, $000F + + setvar $8005, $000F + + setvar $8006, $0FF3 + + setvar $8007, $000F + + special $13B + + sound $5E + + waitstate + + pause $28 + + special $13B + + + + waitstate + + pause $28 + + special $13B + + + + waitstate + + pause $28 + + callasm $2028E57 + + callasm $2028E6D + + callasm $2028E85 + + special $119 + + sound $6B + + waitstate + + pause $28 + + special $139 + + playsong $0166, $0 + + + + + + +.delete_script + killscript + + + + EVENTLEGAL2 + METLOCATION + GAMEORIGIN + + +NoRoomToGive: + virtualmsgbox ItemsPocketIsFull + waitmsg + waitkeypress + release + end + + + +ItemsPocketIsFull: + Text_DE "Lauf und besuche deinen Vater in der\n" + Text_DE "ARENA von BLÜTENBURG CITY.@" + + Text_EN "The TMs Pocket in your Bag\n" + Text_EN "is full.@" + +Lugia: + Text_DE "Lauf und besuche deinen Vater in der@" + + Text_EN "LUGIA: Gyaaas!@" + + + + + + +NormanScriptEnd: + + +PreloadScriptStart: + setvirtualaddress PreloadScriptStart + + clearflag $044D + + virtualloadpointer GoSeeYourFather + + setbyte 2 + + end + + + + + +DataEnd: + EOF + \ No newline at end of file diff --git a/SOURCE/lugiaevent/eonticket.md5 b/SOURCE/lugiaevent/eonticket.md5 new file mode 100644 index 0000000..cb426e5 --- /dev/null +++ b/SOURCE/lugiaevent/eonticket.md5 @@ -0,0 +1 @@ +901180e44767e19e5dc9d5df881fe123 00-C000-EN.z80 diff --git a/SOURCE/lugiaevent/lugia.bin b/SOURCE/lugiaevent/lugia.bin new file mode 100644 index 0000000..37232e3 Binary files /dev/null and b/SOURCE/lugiaevent/lugia.bin differ diff --git a/SOURCE/lugiaevent/lugiapal.bin b/SOURCE/lugiaevent/lugiapal.bin new file mode 100644 index 0000000..d74562e Binary files /dev/null and b/SOURCE/lugiaevent/lugiapal.bin differ diff --git a/SOURCE/lugiaevent/nedclib.dll b/SOURCE/lugiaevent/nedclib.dll new file mode 100644 index 0000000..8a71160 Binary files /dev/null and b/SOURCE/lugiaevent/nedclib.dll differ diff --git a/SOURCE/lugiaevent/nedcmake b/SOURCE/lugiaevent/nedcmake new file mode 100644 index 0000000..45b06a3 Binary files /dev/null and b/SOURCE/lugiaevent/nedcmake differ diff --git a/SOURCE/lugiaevent/nevpk b/SOURCE/lugiaevent/nevpk new file mode 100644 index 0000000..12cf788 Binary files /dev/null and b/SOURCE/lugiaevent/nevpk differ diff --git a/SOURCE/lugiaevent/prologue.asm b/SOURCE/lugiaevent/prologue.asm new file mode 100644 index 0000000..0db33e1 --- /dev/null +++ b/SOURCE/lugiaevent/prologue.asm @@ -0,0 +1,15 @@ +INCLUDE "../macros.asm" +SECTION "prologue", ROM0[$100] + + db "GameFreak inc." + db 0,0,0,0,0,0 + dd 0 + Text "e reader" ; no string terminator + db 0,0,0,0,$01,$55 + db 0,0,0,0 + db REGION + db 0 + db "GameFreak inc." + db 0,0 + + EOF \ No newline at end of file diff --git a/SOURCE/lugiaevent/rgbasm b/SOURCE/lugiaevent/rgbasm new file mode 100644 index 0000000..deb0f72 Binary files /dev/null and b/SOURCE/lugiaevent/rgbasm differ diff --git a/SOURCE/lugiaevent/rgblink b/SOURCE/lugiaevent/rgblink new file mode 100644 index 0000000..c38372b Binary files /dev/null and b/SOURCE/lugiaevent/rgblink differ diff --git a/SOURCE/macros.asm b/SOURCE/macros.asm new file mode 100644 index 0000000..d91b02a --- /dev/null +++ b/SOURCE/macros.asm @@ -0,0 +1,318 @@ +; some Z80 opcodes aren’t supported by Game Boy, +; but are used in e-Reader programs + +; ld [\1], hl +LD_IND_HL: MACRO + db $22, (\1 & $FF), (\1 >> 8) + ENDM +; ld [\1], a +LD_IND_A: MACRO + db $32, (\1 & $FF), (\1 >> 8) + ENDM + +; ld hl, [\1] +LD_HL_IND: MACRO + db $2A, (\1 & $FF), (\1 >> 8) + ENDM +; ld a, [\1] +LD_A_IND: MACRO + db $3A + dw \1 + ENDM + +waita: MACRO + ld a, \1 + db $76 + ENDM +; ld [hl], a +LD_IND_HL_A: MACRO + db $77 + ENDM + +; ld a, [hl] +LD_IND_A_HL: MACRO + db $7E + ENDM + +; ld c, [hl] +LD_IND_C_HL: MACRO + db $4E + ENDM + +; ld b, [hl] +LD_IND_B_HL: MACRO + db $46 + ENDM + +; ld l, [hl] +LD_IND_L_HL: MACRO + db $6E + ENDM + +; ld e, [hl] +LD_IND_E_HL: MACRO + db $5E + ENDM + +; ld d, [hl] +LD_IND_D_HL: MACRO + db $56 + ENDM + +; ld [hl], c +LD_IND_HL_C: MACRO + db $71 + ENDM + +; ld [hl], b +LD_IND_HL_B: MACRO + db $70 + ENDM + +; ld a, [de] +LD_IND_A_DE: MACRO + db $1A + ENDM + +; add a, [hl] +ADD_A_HL_IND: MACRO + db $86 + ENDM + +EX_DE_HL: MACRO + db $EB + ENDM + +wait: MACRO + db $D3, \1 + ENDM + +API: MACRO + db ($C7 + (\1 & $100) >> 5), (\1 & $FF) ; $C7 for API $0xx, $CF for API $1xx + ENDM + + + +dd: MACRO + dw (\1) & $FFFF + dw (\1) >> 16 + ENDM + +RGB: MACRO + dw (\1) | ((\2) << 5) | ((\3) << 10) + ENDM + +GBAPTR: MACRO + dd $02000000 + \1 - ScriptBaseAddress + ENDM + +Insert_Prologue: MACRO + db "GameFreak inc." + db 0,0,0,0,0,0 + dd \1 + db \2 + REPT 8 - STRLEN(\2) + db 0 + ENDR + db 0,0,0,0,$01,$55 + db 0,0,0,0 + db \3 + db 0 + db "GameFreak inc." + db 0,0 + ENDM + +Mystery_Event: MACRO +ScriptBaseAddress EQU $100 + SECTION "mysteryevent", ROM0[$100] + db $01 + dd $02000000 + db REGION,0,REGION,0,0,0,$04,0,$80,$01,0,0 + ENDM + +REGION_JP EQU $01 +REGION_EN EQU $02 +REGION_FR EQU $03 ; ? +REGION_IT EQU $04 ; ? +REGION_DE EQU $05 ; ! +REGION_ES EQU $07 ; ¿? + +; types of card data +END_OF_CHUNKS EQU $02 +LOADING_MESSAGE EQU $03 +SET_LOAD_STATUS EQU $04 +PRELOAD_SCRIPT EQU $05 +IN_GAME_SCRIPT EQU $06 +CUSTOM_BERRY EQU $07 +AWARD_RIBBON EQU $08 +NATIONAL_POKEDEX EQU $09 +ADD_RARE_WORD EQU $0A +MIX_RECORDS_ITEM EQU $0B +GIVE_POKEMON EQU $0C +BATTLE_TRAINER EQU $0D +CLOCK_ADJUSTMENT EQU $0E +CHECKSUM_BYTES EQU $0F ; don’t use this +CHECKSUM_CRC EQU $10 ; use this instead +DOME_TRAINER EQU $11 ; Battle Dome trainer + +; an FF byte followed by 00s will flag the end of the program so that it can +; be extracted automatically from the Game Boy ROM that rgbds tries to build +EOF: MACRO + db $FF + ENDM + + +; names for some API functions based on Martin Korth’s GBATEK +; http://problemkaputt.de/gbatek.htm +FadeIn: MACRO + ld a, \1 + API $000 + ENDM +SetBackgroundAutoScroll: MACRO + ld bc, \1 + ld de, \2 + xor a + API $012 + ENDM +SetBackgroundMode: MACRO + ld e, \1 + push de + xor a + API $019 + ENDM +API_02C: MACRO + ld hl, $0000 + push hl + ld bc, \1 + ld de, \2 + IF \3 == 0 + xor a ; save a byte + ELSE + ld a, \3 + ENDC + API $02C + ENDM +LoadCustomBackground: MACRO + ld de, \1 + IF \2 == 0 + xor a ; save a byte + ELSE + ld a, \2 + ENDC + API $02D + ENDM +SetSpritePos: MACRO + ld bc, \3 + ld de, \2 + LD_HL_IND \1 + API $032 + ENDM +SpriteShow: MACRO + LD_HL_IND \1 + API $046 + ENDM +SpriteHide: MACRO + LD_HL_IND \1 + API $047 + ENDM +SpriteMirrorToggle: MACRO + ld e, \1 + LD_HL_IND \2 + API $048 + ENDM +CreateCustomSprite: MACRO + ld e, \2 + ld hl, \3 + API $04D + LD_IND_HL \1 + ENDM +SpriteAutoScaleUntilSize: MACRO + ld c, \2 + ld de, \3 + LD_HL_IND \1 + API $05B + ENDM +SetBackgroundPalette: MACRO + ld c, \1 + ld de, \2 + ld hl, \3 + API $07E + ENDM +API_084: MACRO + ld l, \4 + push hl + ld bc, \3 + ld de, \2 + LD_HL_IND \1 + API $084 + ENDM +CreateRegion: MACRO + ld bc, (\2 << 8 + \3) + ld de, (\4 << 8 + \5) + ld hl, (\6 << 8 + \7) + API $090 + LD_IND_A \1 + ENDM +SetRegionColor: MACRO + ld e, \2 + LD_A_IND \1 + API $091 + ENDM +CLEAR_REGION: MACRO + LD_A_IND \1 + API $092 + ENDM +SetTextColor: MACRO + ld de, (\2 << 8 + \3) + LD_A_IND \1 + API $098 + ENDM +DrawText: MACRO + CLEAR_REGION \1 + ld bc, \2 + ld de, (\3 << 8 + \4) + LD_A_IND \1 + API $099 + ENDM +SetTextSize: MACRO + API $09A + ENDM +API_09B: MACRO + ld de, \2 + LD_A_IND \1 + API $09B + ENDM +GetTextWidth: MACRO + ld de, \2 + LD_A_IND \1 + API $0C0 + ENDM +API_0C7: MACRO + ld hl, \1 + API $0C7 + ENDM +EXIT: MACRO + API $100 + ENDM +API_106: MACRO + ld de, \1 + ld hl, \2 + API $106 + ENDM +SOUND_PAUSE: MACRO + API $116 + ENDM +IS_SOUND_PLAYING: MACRO + API $08D + ld b, $00 + ld e, $01 + ld hl, $0006 + API $119 + ld a, \1 + EXIT + ENDM +API_121: MACRO + ld de, $0000 + ld hl, $0000 + API $121 + ENDM \ No newline at end of file diff --git a/SOURCE/mewevent/00-C000.asm b/SOURCE/mewevent/00-C000.asm new file mode 100644 index 0000000..5412983 --- /dev/null +++ b/SOURCE/mewevent/00-C000.asm @@ -0,0 +1,174 @@ +INCLUDE "../macros.asm" +SECTION "eonticket",ROM0[$100] +jp Start +db $00 + +TicketSprite: ; 104 + INCBIN "mew.4bpp" +TicketPalette: ; 1604 + INCBIN "mew.gbapal" + +Prologue: + INCBIN "prologue-{REGION_NAME}.bin" + +DataPacket: ; 164a + INCBIN "eonticket-{REGION_NAME}.mev" + db 0,0,0 ; padding + +INCLUDE "../common/mem_struct.asm" + +SpriteData: + dw TicketSprite,TicketPalette + db $8,$8,$01,$01,$01,$01,$01 ; width 15, height 8 + +Instructions1: ; 1921 + db "Link e-Reader to Pokémon Ruby or \n" + db "Sapphire and select MYSTERY EVENTS\n" + db "on the game's main menu.\n" + db "Press the B Button to cancel.\0" + +Instructions2: ; 199d + db "Press the A Button on the Game Boy\n" + db "Advance containing Pokémon Ruby or\n" + db "Sapphire to begin sending the\n" + db "MEW EVENT.\0" + +DeliveryInProcess: ; 1a0d + db "MEW EVENT delivery in Progress...\0" + +TicketDelivered: ; 1a2f + db "MEW EVENT delivered!\n" + db "\n" + db "Press the A Button to resend.\n" + db "Press the B Button to cancel.\0" + +; this function is subtly different than the one +; on the Battle e cards, for no apparent reason +TransferData: + LD_IND_HL SomeVar1 + push de + ld hl, $bbbb + LD_IND_HL Space_1 + EX_DE_HL + LD_IND_HL Space_2 + API_0C7 Space_1 + + wait $01 + pop hl + inc hl + ld b, $01 + call WordShiftRight + + LD_IND_HL SomeVar2 +.asm_1aa1 + LD_HL_IND SomeVar2 + ld a, l + or h + ret z + + ld hl, $8888 + LD_IND_HL Space_1 + ld e, $01 + +.asm_1aaf + ld a, e + cp $08 + jr nc, .asm_1ad9 + + push de + LD_HL_IND SomeVar1 + ld c, [hl] + inc hl + ld b, [hl] + inc hl + LD_IND_HL SomeVar1 + ld l, e + ld h, $00 + add hl, hl + ld de, Space_1 + add hl, de + ld [hl], c + inc hl + ld [hl], b + pop de + LD_HL_IND SomeVar2 + dec hl + LD_IND_HL SomeVar2 + ld a, l + or h + jr z, .asm_1ad9 + + inc e + jr .asm_1aaf + +.asm_1ad9 + API_0C7 Space_1 + wait $01 + jr .asm_1aa1 + +Start: ; 1ae2 + API_121 + + CreateCustomSprite SpriteHandlePtr, $80, SpriteData + SetSpritePos SpriteHandlePtr, 120, 64 + SpriteHide SpriteHandlePtr + + CreateRegion RegionHandlePtr, 30, 6, 0, 14, 0, 4 + + ld h, a + ld l, $00 + SetTextSize + + API_09B RegionHandlePtr, $0102 + SetTextColor RegionHandlePtr, 2, 0 + SetRegionColor RegionHandlePtr, 0 + SetBackgroundPalette 16, $0040, TicketPalette + + FadeIn 16 + wait 16 + + API $0C6 + + DrawText RegionHandlePtr, Instructions1, 8, 4 + API $08D + +INCLUDE "../common/wait_for_link.asm" + + SpriteShow SpriteHandlePtr + + DrawText RegionHandlePtr, Instructions2, 8, 4 + API $08D + + ld a, b + nop + +UNKNOWN_VALUE EQU $0078 +INCLUDE "../common/wait_for_ready.asm" + + DrawText RegionHandlePtr, DeliveryInProcess, 8, 4 + +DATA_TRANSFER_LENGTH EQU 6144 +INCLUDE "../common/transfer_data.asm" + ld hl, $5fff + LD_IND_HL Space_1 + API_0C7 Space_1 + + wait $80 + + SpriteHide SpriteHandlePtr + + DrawText RegionHandlePtr, TicketDelivered, 8, 4 + + API $08D + ld c, a + nop + +INCLUDE "../common/wrap_up.asm" + +INCLUDE "../common/word_shift_right.asm" + +SomeVar1: ; 1CA2 + db $FF,0 ; mark EOF +RegionHandlePtr: db 0 ; 1CA4 +SpriteHandlePtr: db 0,0 ; 1CA5 +SomeVar2: db 0,0 ; 1CA7 \ No newline at end of file diff --git a/SOURCE/mewevent/00-C000.raw b/SOURCE/mewevent/00-C000.raw new file mode 100644 index 0000000..eb53c43 Binary files /dev/null and b/SOURCE/mewevent/00-C000.raw differ diff --git a/SOURCE/mewevent/Makefile b/SOURCE/mewevent/Makefile new file mode 100644 index 0000000..11d6e49 --- /dev/null +++ b/SOURCE/mewevent/Makefile @@ -0,0 +1,40 @@ +all: 00-C000-EN.raw verify +verify: + md5sum --check eonticket.md5 + + +eonticket-%.tx: eonticket.asm + python ../scripts/regionalize.py $< $@ $* $* +eonticket-%.o: eonticket-%.tx + ./rgbasm -o $@ $< +eonticket-%.gbc: eonticket-%.o + ./rgblink -o $@ $< +eonticket-%.bin: eonticket-%.gbc + python ../scripts/stripgbc.py $< $@ +eonticket-%.mev: eonticket-%.bin + python ../scripts/checksum.py $< $@ + +prologue-%.tx: prologue.asm + python ../scripts/regionalize.py $< $@ $* $* +prologue-%.o: prologue-%.tx + ./rgbasm -o $@ $< +prologue-%.gbc: prologue-%.o + ./rgblink -o $@ $< +prologue-%.bin: prologue-%.gbc + python ../scripts/stripgbc.py $< $@ + +00-C000-%.tx: 00-C000.asm eonticket-%.mev prologue-%.bin + python ../scripts/ereadertext.py $< $@ $* +00-C000-%.o: 00-C000-%.tx + ./rgbasm -o $@ $< +00-C000-%.gbc: 00-C000-%.o + ./rgblink -o $@ $< +00-C000-%.z80: 00-C000-%.gbc + python ../scripts/stripgbc.py $< $@ +00-C000-%.vpk: 00-C000-%.z80 + ./nevpk -c -i $< -o $@ +00-C000-%.raw: 00-C000-%.vpk + ./nedcmake -i $< -o $@ -type 1 -region 1 + +clean: + rm -f *.tx *.o *.gbc *.z80 *.bin *.mev *.vpk *.raw \ No newline at end of file diff --git a/SOURCE/mewevent/eonticket.asm b/SOURCE/mewevent/eonticket.asm new file mode 100644 index 0000000..2a5c8d7 --- /dev/null +++ b/SOURCE/mewevent/eonticket.asm @@ -0,0 +1,206 @@ +INCLUDE "../macros.asm" +INCLUDE "../constants/items.asm" +INCLUDE "../constants/scriptcommandsmew.asm" + + Mystery_Event + + db CHECKSUM_CRC + dd 0 ; checksum placeholder + GBAPTR DataStart + GBAPTR DataEnd + +DataStart: + db IN_GAME_SCRIPT + db 0,35 ; Route 119 + db 41 ; item + GBAPTR NormanScriptStart + GBAPTR NormanScriptEnd + + + + db MIX_RECORDS_ITEM + db 1 ; ??? +IF REGION == REGION_DE + db 5 ; distribution limit from German debug ROM +ELSE + db 30 ; distribution limit from English release +ENDC + dw EON_TICKET + + + + db PRELOAD_SCRIPT + GBAPTR PreloadScriptStart + + db END_OF_CHUNKS + + +GoSeeYourFather: + Text_DE "Lauf und besuche deinen Vater in der\n" + Text_DE "ARENA von BLÜTENBURG CITY.@" + + Text_EN "A mirage was spotted on route 120.\n" + Text_EN "There are reports of an elusive Pokémon.@" + + + +NormanScriptStart: + setvirtualaddress NormanScriptStart + + checkitemroom LUM_BERRY, 1 + + compare LASTRESULT, 0 + + virtualgotoif 1, NoRoomToGive + + + + + setwildbattle $97, $1E, $00AE + + copyvarifnotzero $8000, LUM_BERRY + + copyvarifnotzero $8001, 1 + + checkitemtype $0005 + + callstd 1 + + closeonkeypress + + fadeout $3 + + virtualmsgbox Mirage + + waitmsg + + waitkeypress + + release + + setvar $8004, $000F + + setvar $8005, $000F + + setvar $8006, $0FF3 + + setvar $8007, $000F + + special $13D + + sound $13 + + waitstate + + pause $28 + + special $13D + + sound $13 + + waitstate + + pause $28 + + callasm $2028E5D + + callasm $2028E75 + + callasm $2028E8D + + callasm $2028E8D ; change to 2028EA1 for JP mew + + virtualmsgbox Pokemon + + waitmsg + + waitkeypress + + release + + virtualmsgbox Mew + + playmoncry $97, $0 + + waitmoncry + + waitmsg + + waitkeypress + + release + + special $138 + + playsong $0166, $0 + + + + + + +.delete_script + killscript + + + + EVENTLEGAL2 + METLOCATION + GAMEORIGIN + GAMELANG + +NoRoomToGive: + virtualmsgbox ItemsPocketIsFull + waitmsg + waitkeypress + release + end + + + +ItemsPocketIsFull: + Text_DE "Lauf und besuche deinen Vater in der\n" + Text_DE "ARENA von BLÜTENBURG CITY.@" + + Text_EN "The Berry Pocket in your Bag\n" + Text_EN "is full.@" + +Mirage: + Text_DE "Lauf und besuche deinen Vater in der@" + + Text_EN "What’s that light? A mirage?@" + +Pokemon: + Text_DE "Lauf und besuche deinen Vater in der@" + + Text_EN "No, it’s a Pokémon!@" + +Mew: + Text_DE "Lauf und besuche deinen Vater in der@" + + Text_EN "Mew: Mew!@" + + + + +NormanScriptEnd: + + +PreloadScriptStart: + setvirtualaddress PreloadScriptStart + + clearflag $03DB + + virtualloadpointer GoSeeYourFather + + setbyte 2 + + end + + + + + +DataEnd: + EOF + \ No newline at end of file diff --git a/SOURCE/mewevent/mew.4bpp b/SOURCE/mewevent/mew.4bpp new file mode 100644 index 0000000..32e9dd8 Binary files /dev/null and b/SOURCE/mewevent/mew.4bpp differ diff --git a/SOURCE/mewevent/mew.gbapal b/SOURCE/mewevent/mew.gbapal new file mode 100644 index 0000000..216990b --- /dev/null +++ b/SOURCE/mewevent/mew.gbapal @@ -0,0 +1 @@ +{oZkcQIj|||||^sg>:) \ No newline at end of file diff --git a/SOURCE/mewevent/nedclib.dll b/SOURCE/mewevent/nedclib.dll new file mode 100644 index 0000000..8a71160 Binary files /dev/null and b/SOURCE/mewevent/nedclib.dll differ diff --git a/SOURCE/mewevent/nedcmake b/SOURCE/mewevent/nedcmake new file mode 100644 index 0000000..45b06a3 Binary files /dev/null and b/SOURCE/mewevent/nedcmake differ diff --git a/SOURCE/mewevent/nevpk b/SOURCE/mewevent/nevpk new file mode 100644 index 0000000..12cf788 Binary files /dev/null and b/SOURCE/mewevent/nevpk differ diff --git a/SOURCE/mewevent/prologue.asm b/SOURCE/mewevent/prologue.asm new file mode 100644 index 0000000..0db33e1 --- /dev/null +++ b/SOURCE/mewevent/prologue.asm @@ -0,0 +1,15 @@ +INCLUDE "../macros.asm" +SECTION "prologue", ROM0[$100] + + db "GameFreak inc." + db 0,0,0,0,0,0 + dd 0 + Text "e reader" ; no string terminator + db 0,0,0,0,$01,$55 + db 0,0,0,0 + db REGION + db 0 + db "GameFreak inc." + db 0,0 + + EOF \ No newline at end of file diff --git a/SOURCE/mewevent/rgbasm b/SOURCE/mewevent/rgbasm new file mode 100644 index 0000000..deb0f72 Binary files /dev/null and b/SOURCE/mewevent/rgbasm differ diff --git a/SOURCE/mewevent/rgblink b/SOURCE/mewevent/rgblink new file mode 100644 index 0000000..c38372b Binary files /dev/null and b/SOURCE/mewevent/rgblink differ diff --git a/SOURCE/scripts/asmquote.py b/SOURCE/scripts/asmquote.py new file mode 100644 index 0000000..cfc1440 --- /dev/null +++ b/SOURCE/scripts/asmquote.py @@ -0,0 +1,27 @@ +asmProblemBytes = ['\x00', '\x09', '\x0A', '\x22'] +def asmQuote(t): + result = "" + quoted = False + if t[0] in asmProblemBytes: + result = '{0}'.format(ord(t[0])) + else: + result = '"' + t[0] + quoted = True + t = t[1:] + + while len(t): + if quoted and t[0] in asmProblemBytes: + result += '",{0}'.format(ord(t[0])) + quoted = False + elif quoted: + result += t[0] + elif t[0] in asmProblemBytes: + result += ',{0}'.format(ord(t[0])) + quoted = False + else: + result += ',"' + t[0] + quoted = True + t = t[1:] + if quoted: + result += '"' + return result \ No newline at end of file diff --git a/SOURCE/scripts/asmquote.pyc b/SOURCE/scripts/asmquote.pyc new file mode 100644 index 0000000..90786ad Binary files /dev/null and b/SOURCE/scripts/asmquote.pyc differ diff --git a/SOURCE/scripts/checksum.py b/SOURCE/scripts/checksum.py new file mode 100644 index 0000000..8b5f63c --- /dev/null +++ b/SOURCE/scripts/checksum.py @@ -0,0 +1,89 @@ +import struct +import sys + +chunk_lengths = [0,0,0,6,2,5,12,5,3,1,2,5,5,5,1,13,13] + +bytewises = [] +bytewise_results = [] +wordwises = [] +wordwise_results = [] +crcs = [] +crc_results = [] + +data = "" +with open(sys.argv[1], 'rb') as f: + data = f.read() +f.closed + +base_address = struct.unpack(' 0x10: + print "Unknown chunk {0:X}".format(chunk_type) + raise TypeError + i += chunk_lengths[chunk_type] + + +# calculate and insert all wordwise checksums +for wordwise in wordwises: + sum = 0 + for i in range(wordwise[1], wordwise[2], 4): + sum = (sum + struct.unpack('> 1) ^ 0x8408 + else: + sum >>= 1 + sum = ~sum & 0xFFFF + crc_results.append(sum) + +i = 0 +for crc in crcs: + data = data[0:crc[0]] + struct.pack(' 0x11: + print "Unknown chunk {0:X}".format(chunk_type) + raise TypeError + i += chunk_lengths[chunk_type] + + + +# calculate and insert all wordwise checksums +for wordwise in wordwises: + sum = 0 + for i in range(wordwise[1], wordwise[2], 4): + sum = (sum + struct.unpack('> 1) ^ 0x8408 + else: + sum >>= 1 + sum = ~sum & 0xFFFF + crc_results.append(sum) + +i = 0 +for crc in crcs: + data = data[0:crc[0]] + struct.pack('= 0xF0: + char += t[0:4] + t = t[4:] + elif ord(t[0]) >= 0xE0: + char += t[0:3] + t = t[3:] + elif ord(t[0]) >= 0xC0: + char += t[0:2] + t = t[2:] + else: + char += t[0:1] + t = t[1:] + if char != "\\" and char != "\\v" and (char[0:2] != "\\{" or char[-1] == "}"): + characters.append(char) + char = "" + + result = "" + for char in characters: + result += chars[char] + return result + +def asmQuote(t): + result = "" + quoted = False + if t[0] in asmProblemBytes: + result = '{0}'.format(ord(t[0])) + else: + result = '"' + t[0] + quoted = True + + while len(t): + if quoted and t[0] in asmProblemBytes: + result += '",{0}'.format(ord(t[0])) + quoted = False + elif quoted: + result += t[0] + elif t[0] in asmProblemBytes: + result += ',{0}'.format(ord(t[0])) + quoted = False + else: + result += ',"' + t[0] + quoted = True + t = t[1:] + if quoted: + result += '"' + return result \ No newline at end of file diff --git a/SOURCE/scripts/gen3text.pyc b/SOURCE/scripts/gen3text.pyc new file mode 100644 index 0000000..42c2cf6 Binary files /dev/null and b/SOURCE/scripts/gen3text.pyc differ diff --git a/SOURCE/scripts/pokemonstructure.py b/SOURCE/scripts/pokemonstructure.py new file mode 100644 index 0000000..599e935 --- /dev/null +++ b/SOURCE/scripts/pokemonstructure.py @@ -0,0 +1,210 @@ +# -*- coding: utf-8 -*- +import struct +import sys + +data = "" +dataout="" +with open(sys.argv[1], 'rb') as f: + data = f.read() +f.closed + +pv=struct.unpack('> 24 +key3 = ((pv ^ otid) >> 16) & mask +key2 = ((pv ^ otid) >> 8) & mask +key1 = (pv ^ otid) & mask + +substructG=[struct.unpack('> 8) + data[66:] + +i=0 +while i < 12: + substructG[i] ^= key1 + substructA[i] ^= key1 + substructE[i] ^= key1 + substructM[i] ^= key1 + substructG[i+1] ^= key2 + substructA[i+1] ^= key2 + substructE[i+1] ^= key2 + substructM[i+1] ^= key2 + substructG[i+2] ^= key3 + substructA[i+2] ^= key3 + substructE[i+2] ^= key3 + substructM[i+2] ^= key3 + substructG[i+3] ^= key4 + substructA[i+3] ^= key4 + substructE[i+3] ^= key4 + substructM[i+3] ^= key4 + i+=4 + + +mod = pv % 24 +i=0 +if mod == 0: + for i in range(12): + data = data[0:68+i] + struct.pack(' 0: + asms[1] += '\xFF' + for i in range(padding - 1): + asms[1] += "\x00" + except ValueError: + pass + out.write("db " + asmQuote(asms[1]) + "\n") + elif len(command) < 5 or command[0:5] != "Text_": + out.write(asm) + if "macros.asm" in asm: + # can’t do this until after REGION_EN, etc. are loaded + out.write("REGION EQU REGION_" + data_region + "\n") + # else this is foreign text, delete it +f.closed \ No newline at end of file diff --git a/SOURCE/scripts/stripgbc.py b/SOURCE/scripts/stripgbc.py new file mode 100644 index 0000000..146d119 --- /dev/null +++ b/SOURCE/scripts/stripgbc.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +import sys + +out = open(sys.argv[2], 'w') +buffering = False +buf = "" +with open(sys.argv[1], 'rb') as f: + f.read(256) # skip to $0100 + while True: + byte = f.read(1) + if not byte: + break + + # the program shall end with $FF followed only by $00 bytes + # for every $FF we hit, buffer until something that isn’t $00 + if (not buffering and ord(byte) == 0xFF) or (buffering and ord(byte) == 0x00): + buf += byte + buffering = True + elif buffering and ord(byte) == 0xFF: + out.write(buf) + buf = byte + elif buffering: + out.write(buf) + out.write(byte) + buf = "" + buffering = False + else: + out.write(byte) +f.closed \ No newline at end of file