Last modified on 16 January 2016, at 05:43

Programming:Next / previous line calculation

Revision as of 05:43, 16 January 2016 by Fgbrain (Talk | contribs) (Firmware)

Next line

This routines calculate the next line from the given address.

Firmware

Input: HL=Address

Output: HL=Address of the next line

Destroyed: AF

SCR_NEXT_LINE equ #BC26

call SCR_NEXT_LINE


ACTUAL #BC26 ROUTINE FOLLOWS:

ld a,h:add #08:ld h,a:and #38:ret nz
ld a,h:sub #40:ld h,a:ld a,l:add reg1*2:ld l,a:ret nc  ;reg1= CRTC reg.1 value
inc h:ld a,h:and #07:ret nz
ld a,h:sub #08:ld h,a:ret


Without Firmware

Input: HL=Address

Output: HL=Address of the next line

Destroyed: AF,BC

; Richard Fairhurst 
; October 1997 
; 
;*** Next line down from HL *** 

.nline  ld a,8 
        add h 
        ld h,a 
        ret nc
        ld bc,#c050
        add hl,bc 
        ret

Previous line

This routines calculate the previous line from the given address.

Firmware

Input: HL=Address

Output: HL=Address of the previous line

Destroyed: AF

SCR_PREV_LINE equ #BC29

call SCR_PREV_LINE