Main Menu
Main Page
Forums
New pages
Recent changes
Random page
Help

Glitches
Arbitrary code execution
Pokémon cloning
Pomeg glitch and Glitzer Popping
Tweaking and voiding
Glitches by generation
Other glitch categories

References/Resources
Databases
Disassembly projects
The Big HEX List
Interactive tools
Reference documents
Terminology

Affiliates
Legendary Star Blob 2 (Hakuda) (日本語/Japanese)
Pokémon Speedruns wiki (English)
PRAMA Initiative (Français/French)
MissingNo. Glitch City (Italiano/Italian)
Become an affiliate!

Technical
Site source code

Search Wiki

 

Search Forums

 

Author Topic: Pokemon Blue plays itself (TPP)  (Read 4364 times)

0 Members and 1 Guest are viewing this topic.

luckytyphlosion

  • Distinguished Member
  • *
  • Offline Offline
  • Gender: Male
  • JACK-flys are OP
    • View Profile
Pokemon Blue plays itself (TPP)
« on: January 01, 2015, 12:53:27 pm »
It took me so long to figure out how I could do this, but I finally figured out!

Every frame, the OAM DMA is called (or something like that I don't know it very well), but if you redirect the code somewhere else in HRAM, you can have the game perform instructions every frame!

The way I did it:

At FF86, write "jr FFF9".
At FFF9, write "dec a"
At FFFA, write "jr nz, FFF9"
At FFFC, write "jp D34A"

D34A is the rival name, so it can be never changed through normal gameplay.

At D34A, write "ld a,(FFD3)"
At D34D, write "ld (FFF8),a"
At D350, write "ret"

This will write a random value to FFF8 every frame (I think, correct me if I'm wrong). FFF8 is the joypad, so the game is essentially pressing random buttons every single frame.

Now, the only problem is that I'm not exactly sure if the game is doing "OAM DMA Bad Accesses", since Sanqui says BGB doesn't emulate that part correctly, but the OAM DMA is called at the correct time, so I don't think anything bad is happening.

Evie (retired from head adminship)

  • Veteran Contributor
  • *
  • Online Online
  • Gender: Female
    • View Profile
Re: Pokemon Blue plays itself (TPP)
« Reply #1 on: January 01, 2015, 01:12:05 pm »
Awesome. Is that possible with 8F, or only a custom map script? Will the effects be 'permanent'?
« Last Edit: January 01, 2015, 01:29:21 pm by Torchickens »

✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿
Here have some free flowers on every post :)
✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿



(Images © Sanrio, Nintendo, Pokémon, HAL Laboratory) Sorry I don't know who made the Eevee butterfly fan art :(

✿ Hi, I'm Evie. No longer active here other than to answer questions, messages. Sorry I've had to step down and have demoted myself (will explain later). I suggest contacting Photon-Phoenix/Yuzihax, and Abwayax.

Forgiveness. I feel that the more people pray to our greatest source/God/mathematical equality for world peace, the more and more it manifests into reality (until our next spiritual death).

Thank you Nyapon for this lovely artwork. :3

luckytyphlosion

  • Distinguished Member
  • *
  • Offline Offline
  • Gender: Male
  • JACK-flys are OP
    • View Profile
Re: Pokemon Blue plays itself (TPP)
« Reply #2 on: January 01, 2015, 01:25:00 pm »
As long as you don't reset, then the effects "should" be permanent. I made sure the portion of HRAM the jump relative sends you to in order to complete the OAM DMA is unused. You can probably structure the code with 8F, but it would need to be done in one go.

Evie (retired from head adminship)

  • Veteran Contributor
  • *
  • Online Online
  • Gender: Female
    • View Profile
Re: Pokemon Blue plays itself (TPP)
« Reply #3 on: January 01, 2015, 01:29:36 pm »
It white screened for me on both BGB and VBA. Do you know why? I entered the right ASM/opcodes. I'll try Pokémon Blue instead of Red.

Edit: I accidentally entered code in the wrong addresses, sorry.
Edit 2: This is hilarious on turbo mode, ha ha :). One time Red used 8F (I just edited the memory, haven't set up code yet), freezing the game.
Edit 3: Why don't you just use this?

At FF86, write "jr FFF9".
At FFF9, write "jp D34A"

At D34A, write "ld a,(FFD3)"
At D34D, write "ld (FFF8),a"
At D350, write "ret"

Does your code add some delay before the next button of some sort, because the game only jumps to D34A in yours if a is 0?
« Last Edit: January 01, 2015, 02:04:56 pm by Torchickens »

✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿
Here have some free flowers on every post :)
✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿



(Images © Sanrio, Nintendo, Pokémon, HAL Laboratory) Sorry I don't know who made the Eevee butterfly fan art :(

✿ Hi, I'm Evie. No longer active here other than to answer questions, messages. Sorry I've had to step down and have demoted myself (will explain later). I suggest contacting Photon-Phoenix/Yuzihax, and Abwayax.

Forgiveness. I feel that the more people pray to our greatest source/God/mathematical equality for world peace, the more and more it manifests into reality (until our next spiritual death).

Thank you Nyapon for this lovely artwork. :3

luckytyphlosion

  • Distinguished Member
  • *
  • Offline Offline
  • Gender: Male
  • JACK-flys are OP
    • View Profile
Re: Pokemon Blue plays itself (TPP)
« Reply #4 on: January 01, 2015, 02:11:45 pm »
I need to complete the OAM DMA before I can jump to D34A; the extra code in my post was to complete it because I removed some code in the OAM DMA, so I needed to add it somewhere else.

Evie (retired from head adminship)

  • Veteran Contributor
  • *
  • Online Online
  • Gender: Female
    • View Profile
Re: Pokemon Blue plays itself (TPP)
« Reply #5 on: January 01, 2015, 02:16:58 pm »
I need to complete the OAM DMA before I can jump to D34A; the extra code in my post was to complete it because I removed some code in the OAM DMA, so I needed to add it somewhere else.

I don't really get that, but it seems to work perfectly without dec a and jr nz, FFF9. Well maybe because of an emulation error. Dunno. Would it not work on a real Game Boy?
« Last Edit: January 01, 2015, 02:20:38 pm by Torchickens »

✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿
Here have some free flowers on every post :)
✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿



(Images © Sanrio, Nintendo, Pokémon, HAL Laboratory) Sorry I don't know who made the Eevee butterfly fan art :(

✿ Hi, I'm Evie. No longer active here other than to answer questions, messages. Sorry I've had to step down and have demoted myself (will explain later). I suggest contacting Photon-Phoenix/Yuzihax, and Abwayax.

Forgiveness. I feel that the more people pray to our greatest source/God/mathematical equality for world peace, the more and more it manifests into reality (until our next spiritual death).

Thank you Nyapon for this lovely artwork. :3

luckytyphlosion

  • Distinguished Member
  • *
  • Offline Offline
  • Gender: Male
  • JACK-flys are OP
    • View Profile
Re: Pokemon Blue plays itself (TPP)
« Reply #6 on: January 01, 2015, 02:31:33 pm »
I'm not so sure. From FF80-FF89, code is executed there every vblank, so I want to make sure that it's successfully executed.

Evie (retired from head adminship)

  • Veteran Contributor
  • *
  • Online Online
  • Gender: Female
    • View Profile
Re: Pokemon Blue plays itself (TPP)
« Reply #7 on: January 01, 2015, 02:35:30 pm »
I'm not so sure. From FF80-FF89, code is executed there every vblank, so I want to make sure that it's successfully executed.

OK. Thanks then. Going to try this on an SP using my Xploder GB :).

Edit: The original code works. Will test other one.
Edit 2: The other one doesn't work on SP. It was an emulation error. You were right.

By the way, for people who don't know how to find them, the GameShark codes for all this are:

Part 1, rival's name (Enable this first. Preferably save with it)
01FA4AD3
01D34BD3
01FF4CD3
01EA4DD3
01F84ED3
01FF4FD3
01C950D3

Part 2, jump/complete OAM DMA (Enable this when you load your save with the rival's name)

011886FF
017187FF
013DF9FF
0120FAFF
01FDFBFF
01C3FCFF
014AFDFF
01D3FEFF

These don't work on my VBA, only on my actual Game Boy Advance SP using Xploder, and BGB.
« Last Edit: January 01, 2015, 03:20:36 pm by Torchickens »

✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿
Here have some free flowers on every post :)
✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿



(Images © Sanrio, Nintendo, Pokémon, HAL Laboratory) Sorry I don't know who made the Eevee butterfly fan art :(

✿ Hi, I'm Evie. No longer active here other than to answer questions, messages. Sorry I've had to step down and have demoted myself (will explain later). I suggest contacting Photon-Phoenix/Yuzihax, and Abwayax.

Forgiveness. I feel that the more people pray to our greatest source/God/mathematical equality for world peace, the more and more it manifests into reality (until our next spiritual death).

Thank you Nyapon for this lovely artwork. :3

luckytyphlosion

  • Distinguished Member
  • *
  • Offline Offline
  • Gender: Male
  • JACK-flys are OP
    • View Profile
Re: Pokemon Blue plays itself (TPP)
« Reply #8 on: January 01, 2015, 03:25:40 pm »
I guess you need to use BGB then. VBA apparently incorrectly emulates "Modify Timing" (the other inaccuracies are just soundstuff and things that all other emulators fail on, which are OAM bugs) according to this, but I'm not sure what it is.

Evie (retired from head adminship)

  • Veteran Contributor
  • *
  • Online Online
  • Gender: Female
    • View Profile
Re: Pokemon Blue plays itself (TPP)
« Reply #9 on: January 01, 2015, 03:35:24 pm »
Oh, so that may be the problem.

Most of the time I'm not going to switch to BGB (only when I need to, for this and for debugging), because VBA is not that inaccurate (although I imagine accuracy is much more important for speedrunning). Even though it has sound glitches, the echo RAM glitch that apparently affected earlier versions is gone in later versions, and I like its in-built recorder; which I think is more convenient than BGB's (which takes many screenshots and audio, and you have to join the two together).

I'll test if this works on Bizhawk, because that has an in-built recorder like VBA's.
« Last Edit: January 01, 2015, 03:37:07 pm by Torchickens »

✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿
Here have some free flowers on every post :)
✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿



(Images © Sanrio, Nintendo, Pokémon, HAL Laboratory) Sorry I don't know who made the Eevee butterfly fan art :(

✿ Hi, I'm Evie. No longer active here other than to answer questions, messages. Sorry I've had to step down and have demoted myself (will explain later). I suggest contacting Photon-Phoenix/Yuzihax, and Abwayax.

Forgiveness. I feel that the more people pray to our greatest source/God/mathematical equality for world peace, the more and more it manifests into reality (until our next spiritual death).

Thank you Nyapon for this lovely artwork. :3

Dabomstew

  • Member+
  • Offline Offline
  • CHARIZRAD 'M ROXORX or is it.
    • View Profile
Re: Pokemon Blue plays itself (TPP)
« Reply #10 on: January 01, 2015, 03:45:40 pm »
Well, I read over some gameboy docs to figure out if lucky's code working was just a fluke or perfectly fine. And the result is, it's perfectly fine:

(chat logs quoted)

Quote
[10:47:08]   dabomstew   okay lucky i researched oam dma a bit and i know why your code works now lol
[10:47:20]   dabomstew   if you wanted more info still
[10:47:50]   dabomstew   ok so
[10:48:05]   dabomstew   "oam dma" is only up to the bit where you're deccing a until it's 0
[10:48:27]   dabomstew   basically the "dec a until it's 0" bit is forcing the cpu to wait in hram long enough for the DMA to complete
[10:48:38]   dabomstew   then after it's done, the game normally returns straight away
[10:48:49]   dabomstew   basically you just hijacked that so it doesn't return straight away
[10:48:57]   dabomstew   and you're not in the DMA time period anymore, so you can do whatever you want
[10:49:08]   dabomstew   provided you let the "dec a" bit happen
[10:49:14]   dabomstew   removing that is not allowed

Evie (retired from head adminship)

  • Veteran Contributor
  • *
  • Online Online
  • Gender: Female
    • View Profile
Re: Pokemon Blue plays itself (TPP)
« Reply #11 on: January 01, 2015, 04:00:39 pm »
This works on BizHawk too.

I wasn't paying attention, but at 00:09 in-game time the game reset so the random buttons effect no longer occurred. Would it be viable to disable soft-resetting? You'd have to make the game not set FFF8 to 0F. I don't know for sure if it was a soft-reset though.

Edit: In other news, I did this on my real Game Boy again. Red hasn't left the house yet xD. I got a soft reset eventually like what happened on Bizhawk.
« Last Edit: January 01, 2015, 04:26:03 pm by Torchickens »

✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿
Here have some free flowers on every post :)
✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿



(Images © Sanrio, Nintendo, Pokémon, HAL Laboratory) Sorry I don't know who made the Eevee butterfly fan art :(

✿ Hi, I'm Evie. No longer active here other than to answer questions, messages. Sorry I've had to step down and have demoted myself (will explain later). I suggest contacting Photon-Phoenix/Yuzihax, and Abwayax.

Forgiveness. I feel that the more people pray to our greatest source/God/mathematical equality for world peace, the more and more it manifests into reality (until our next spiritual death).

Thank you Nyapon for this lovely artwork. :3

luckytyphlosion

  • Distinguished Member
  • *
  • Offline Offline
  • Gender: Male
  • JACK-flys are OP
    • View Profile
Re: Pokemon Blue plays itself (TPP)
« Reply #12 on: January 01, 2015, 04:45:26 pm »
The easiest way to prevent a soft reset is to "res 2,a" so that the select button will never be put into joypad.

Evie (retired from head adminship)

  • Veteran Contributor
  • *
  • Online Online
  • Gender: Female
    • View Profile
Re: Pokemon Blue plays itself (TPP)
« Reply #13 on: January 01, 2015, 04:52:52 pm »
The easiest way to prevent a soft reset is to "res 2,a" so that the select button will never be put into joypad.

Wow, that's nice and easy.

✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿
Here have some free flowers on every post :)
✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿



(Images © Sanrio, Nintendo, Pokémon, HAL Laboratory) Sorry I don't know who made the Eevee butterfly fan art :(

✿ Hi, I'm Evie. No longer active here other than to answer questions, messages. Sorry I've had to step down and have demoted myself (will explain later). I suggest contacting Photon-Phoenix/Yuzihax, and Abwayax.

Forgiveness. I feel that the more people pray to our greatest source/God/mathematical equality for world peace, the more and more it manifests into reality (until our next spiritual death).

Thank you Nyapon for this lovely artwork. :3

luckytyphlosion

  • Distinguished Member
  • *
  • Offline Offline
  • Gender: Male
  • JACK-flys are OP
    • View Profile
Re: Pokemon Blue plays itself (TPP)
« Reply #14 on: January 01, 2015, 05:55:05 pm »
I'm trying to make the game pick random buttons on a bias (modified version of RNGPlaysPokemon's bias), but I'm not exactly sure how I could create a bias on each button. My current plan was:

16/256 = Start
40/256 = A
24/256 = B
44/256 = Up
44/256 = Down
44/256 = Left
44/256 = Right

However, making each button have that chance of being called won't make each button have that bias. Does anyone know how you could create a bias like that?

EDIT: I've decided to just put the chances of each button being called as:

80/256 = Start
100/256 = A
88/256 = B
108/256 = Up
108/256 = Down
108/256 = Left
108/256 = Right

Now all I need to do is write the ASM. I'm writing it in the Pokemon Daycare data, and adding code to always alternate between Down and B if the player ever enters the daycare. (incase you get the very slim chance of a text box appearing, like repel text or poison text)

EDIT2: So my plan of adding Bias to buttons failed, because I ran out of space before I reached into box addresses. Maybe I could use SRAM, though, but apparently on BGB control panel, there's "Inaccessible VRAM", so maybe I could use that? (as long as it doesn't mean the VRAM won't be displayed on screen, but it can still be used).

Otherwise, I could just shorten the code to divide the chance of start button being called up by 1/2.
(code if anyone wants to know)
Code: [Select]
wFlags_DA48: ; really just W_DAYCARE_IN_USE, used to alternate the Down and B button presses when in the daycare
db 00
IsInDaycare_DA49:
ld a,(D35E) ; w_curmap
sub a,48 ; are we in the daycare?
or a ; clears carry flag, but keeps the result of a for the incoming nz check
jr nz,.InitRandomButtons ; if not, start random buttons
ld hl,wFlags
inc (hl)
bit 0,(hl)
jr nz,.asm_pressb
ld a,80
jr .scf
.asm_pressb_DA5D
ld a,02
.scf_DA5F
scf
.InitRandomButtons_DA60
ld hl,FFF8
ld (hl),a
res 2,(hl)
ret c

.AButton_DA67
call GetRandom
cp a,9B
jr c,BButton
set 0,(hl)

.BButton_DA6F
call GetRandom
cp a,A7
jr c,.StartButton
set 1,(hl)

.StartButton_DA77
call GetRandom
cp a,AF
jr c,.RightButton
set 3,(hl)

.RightButton_DA7F
call GetRandom
cp a,93
jr c,LeftButton
set 4,(hl)

.LeftButton_DA
call GetRandom
cp a,93
jr c,UpButton
set 5,(hl)

.UpButton
call GetRandom
cp a,93
jr c,DownButton
set 6,(hl)

.DownButton
call GetRandom
cp a,93
ret c
set 7,(hl)
;fallthrough
GetRandom:
ld a,($FF00+04) ; rDiv
ret
« Last Edit: January 01, 2015, 11:04:59 pm by luckytyphlosion »