z80 BankSwitch reset/initialize

For anything related to sound (YM2612, PSG, Z80, PCM...)

Moderator: BigEvilCorporation

Post Reply
Jpg3D
Interested
Posts: 20
Joined: Mon Mar 03, 2014 9:19 pm

z80 BankSwitch reset/initialize

Post by Jpg3D » Thu Apr 27, 2017 6:03 pm

Hi spritesmind users.

i have searched for some documentation about z80 bank register. Because i'm implementing my own z80 sound driver.

After reading this helpfull document https://emu-docs.org/Genesis/gen-hw.txt i found that i only have to write one by one the 9 high bits of my window direction to the register's bit 0 and Boom! the bank switch should be done. My doubt is about the use of this register. As i have not found how to reset this register, i dont know if the index of the bits that i 'm going to write will be in the right offset. Starting at bit 15

Is there a way to "reset" or "initialize" this register so i'll be sure that my first write will be interpreted as the 15th bit?
Does resetting the z80 resets this register?

I dont know if i explained myself.
I hope you can help me with this little trouble because i want to show you some of my work when it's sufficiently developed.
Thank you.
Last edited by Jpg3D on Thu Apr 27, 2017 6:17 pm, edited 1 time in total.

Mask of Destiny
Very interested
Posts: 615
Joined: Thu Nov 30, 2006 6:30 am

Re: z80 BankSwitch reset

Post by Mask of Destiny » Thu Apr 27, 2017 6:12 pm

The bank register is a simple serial shift register. Each time you write to it a bit is shifted in as the new most significant bit, with the existing bits shifted to the right by one, with the old least significant bit getting shifted out entirely. Effectively, each time you write it's always the new bit 23. If you write 9 values in sequence, the first one will always end up being bit 15.

Jpg3D
Interested
Posts: 20
Joined: Mon Mar 03, 2014 9:19 pm

Re: z80 BankSwitch reset/initialize

Post by Jpg3D » Thu Apr 27, 2017 6:28 pm

Really thank you for your fast and clear answer. Now i fully understand how to use that register.

Post Reply