# Glitch City Laboratories Archives

Glitch City Laboratories closed on 1 September 2020 (announcement). This is an archived copy of a thread from Glitch City Laboratories Forums.

You can join Glitch City Research Institute to ask questions or discuss current developments.

You may also download the archive of this forum in .tar.gz, .sql.gz, or .sqlite.gz formats.

## Programming/Scripting/Development/Web Design

### Need help with padding an 8F script - Page 1

Previous Page

- 1

Next Page

#### Need help with padding an 8F script

Posted by: Couldntthinkofaname
Date: 2017-10-08 10:25:10
So last week I made an item script that could grant you any Pokemon you desire by the amount of times you pressed right.
For example, if you wanted Mew, you would press:
RIGHT x21
SELECT - exit
Here's The code, commented to the best of my ability:
`
dec a ;-padding-
ld c,d ; c = $00
start:
call $3ffa ; calls joypad subroutine
ldh a,($b2) ; Grab most recently released button
cp $10 ; If that button is right...
jr z,righthandler ; ...then go to righthandler
cp $20 ; If that button is left...
jr z,lefthandler ;...then go to lefthandler
ldh a,($f8) ; Get current held button
cp $04 ; If that button is select...
jr z,end ; Go to the end
jr start ; Keep listening for inputs
righthandler:
inc c ; Every time right is pressed, increment c
jr start ; Keep listening for inputs
lefthandler:
dec c ; Every time left is pressed, decrement c
jr start ; Keep listening for inputs
end:
ld b,c ; B = C, B is used as the Species Index
ld c,$32 ;c + $32(50) , C is used as level.
call $3e48 ; Calls pokemon recieve subroutine
ret ; "It''s first grade, Spongebob!"
`
The code works perfectly fine as written, the only problem is I've been attempting to add padding (useless filler to prevent glitch items) to the code, but I can't seem to figure out how I would go about padding this script. Every time I add padding to fix one problem, another arises, and it's frustrating because I want to finish this soon.
Any and all help is appreciated.

#### Re: Need help with padding an 8F script

Posted by: Parzival
Date: 2017-10-08 19:44:04
Padding is what makes Microsoft and Apple products inferior.
Simple answer? Don't.
But if you absolutely have to, use Gold Teeth, Elixer and Poke Flute, and quantities 40h, 52h, and 49h respectively. These correspond to (in order):
`ld b,b
ld c,c
ld d,d`
These just waste time. Some emulators may see them as breakpoints, however, so be careful.

#### Re: Need help with padding an 8F script

Posted by: ISSOtm
Date: 2017-10-10 18:30:25

> Padding is what makes Microsoft and Apple products inferior.
> Simple answer? Don't.

Problem is, padding is almost always required when writing 8F setups - quantities are free, items aren't.
Also, performance is way not an issue here.

> The code works perfectly fine as written, the only problem is I've been attempting to add padding (useless filler to prevent glitch items) to the code, but I can't seem to figure out how I would go about padding this script. Every time I add padding to fix one problem, another arises, and it's frustrating because I want to finish this soon.

The biggest issue with padding is that it is very situational. I came up with a very large setup, which thus doesn't fit in the bag, so it's split across the bag and the PC.
In your bag :
`
8F
Any item
Antidote x14
Great Ball x13
Ice Heal x65
Parlyz Heal x5
Awakening x178
Thunderstone x59
TM13 x233
`
In your PC :
`
TM05 x175
Fire Stone x12
TM42 x87
TM03 x55
Antidote x5
Protein x61
Rare Candy x241
Poké Ball x37
Soda Pop x40
Burn Heal x21
Calcium x21
Moon Stone x32
TM30 x7
Awakening x100
Thunderstone x72
Lemonade x233
Poké Ball x24
TM20 x[Any qty]
`
Also this setup was pretty neat, since it made me find out 4 different bugs in GBz80 to Items. Always grinding for improvements !
(If you want to know, the four bugs were : AND, OR, XOR and CP breaking the label system ; missing "ld a, (FF00+c)" and vice-versa ; incorrect opcode selection for CB instructions ; incorrect jr offset calculation)
Source code :
`
; In the bag (loader code)
dec bc ; Padding
ld c,3
dec c ; c = 2
dec c ; c = 1
ld b, c ; b = 1
rrca ; Padding
dec b ; b = 0
ld c, $B2 ; To be able to use ($FF00+c)
ld hl, $D53B
jp hl
; In the PC (@D53B)
start:
call $20AF ; DelayFrame
inc c ; Padding
ld a,(FF00+c)
ld d, a
swap a
dec bc ; Padding
dec b
inc h ; Padding
dec a
jr z,start ; If the player released Left, then restart with b decremented once
inc b
dec h ; Padding
dec a
jr z,right
dec d
daa ; Padding
dec d
ld a, (bc) ; Padding
jr nz,start
rlca ; Padding
ld c,$64
ld hl, $3e48 ; GivePokemon
jp hl
right:
inc b
jr start
`

#### Re: Need help with padding an 8F script

Posted by: Couldntthinkofaname
Date: 2017-10-11 10:56:38
Thank you!
Previous Page

- 1

Next Page