Ok so lately I have been fidling around with the magic register 26 and 27 to obtain smooth per pixel scrolling and I have got it to work. Scrolls both right and left and it just looks very nice. However the amount of code I had to write to get this to work is ridicoulus. Tons of branching and comparing. This cannot be right. There has got to be a more efficient way to do this.
Please dont ask me why using the V9958 stuff because the awnser will be. I didn't go through hours of soldering and days of prepping to just NOT use these newly added registers 

so here is the code. Go ahaid and laugh at it and after you are finished doing that tell me what can be done to make this terror more easy. 
;wait until space is pressed for exit of left/right key for scrolling
WAIT:
LD HL,&HFBED
LD A,(HL)
BIT 0,A
RET Z
HALT ;to make the scrolling slow down a little bit
LD E,A
BIT 4,A
CALL Z,SCROLL
BIT 7,A
CALL Z,SCROLR
JR WAIT
;scroll to right
SCROLR:
DI
LD HL,SCRLA
LD A,(HL)
DEC A
LD C,A
CP 255
CALL Z,SCRSR
LD (HL),A
OUT (&H99),A
LD A,27+128
OUT (&H99),A
LD HL,SCRLB
LD A,(HL)
OUT (&H99),A
LD A,26+128
OUT (&H99),A
EI
LD A,C ;did we reach 0??
CP 0
RET NZ
SCRSR: ;yes then set the proper values
LD HL,SCRLB
LD A,(HL)
INC A
LD (HL),A
LD HL,SCRLA
LD (HL),8
LD HL,SCRLB
LD A,(HL)
CP 64
LD C,0
RET NZ
LD (HL),0
RET
;scrollen to left
SCROLL:
DI
LD HL,SCRLA
LD A,(HL)
INC A
CP 9
CALL Z,DECSC
CP 8
LD (HL),A
CALL Z,DECSC
LD HL,SCRLB
LD A,(HL)
OUT (&H99),A
LD A,26+128
OUT (&H99),A
LD HL,SCRLA
LD A,(HL)
LD (HL),A
OUT (&H99),A
LD A,27+128
OUT (&H99),A
EI
SET 7,A ;secure arrow keys from strugling
RET
DECSC:
LD (HL),A
LD HL,SCRLA
LD (HL),0
LD HL,SCRLB
LD A,(HL)
DEC A
LD (HL),A
LD HL,SCRLB
LD A,(HL)
CP 0
RET NZ
LD (HL),64 ;register 26 limit reached
RET
SCRLA:
DB 8
SCRLB:
DB 0
end
!login ou Inscrivez-vous pour poster
