Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
clearbox
#7
I've expanded the routine so it can also save and restore portions of the screen:

Code:
CLS

FOR n=1 TO 300
PRINT n;
NEXT n

screenBox(2,3,18,11,2,35000)

pause 0


screenBox (2,3,18,11,1,35000)

pause 0

cls

screenBox (3,11,18,11,3,35000)

screenBox (4,9,18,11,3,35000)


pause 0

end

SUB screenBox(x AS UBYTE, y AS UBYTE, width AS UBYTE, height AS UBYTE, mode AS ubyte, address AS uinteger)

ASM
    
    push de
    ld d, (ix+15)
    ld e, (ix+14)
    ld (counter),de

    ld a, (IX+13)
    ld (modeflag),a
    pop de
    
      ld b,(IX+5)  
      ld c,(IX+7)    
    
    ld a, c            
    AND 24        
    OR 64        
    ld h, a        
    ld a, c        
    AND 7        
    rra            
    rra            
    rra            
    rra            
    add a, b    
    ld l, a        

    ld b, (IX+11)    
    ld c,(IX+9)             

    
    resbox_outer_loop:
        XOR a
        push bc                     
        push hl                     
        ld d, 8                     


                resbox_mid_loop:
                ld e,l                                       
                   ld b,c                                       
            
                    ld a,(modeflag)
                    sub 2
                    jp z,saveMode
                    
                    ld a,(modeflag)
                    sub 3
                    jp z,restoreMode
                    
                    ld a,0
                    clearMode:
                    ld (hl),a                                
                    inc l                                    
                    djnz clearMode
                    jp goOn
                    
                saveMode:
                    push de
                    ld de, (counter)
                    saveBox_inner_loop:
                    ld a,(hl)                                
                    ld (de),a
                    inc l                                    
                    inc de
                    djnz saveBox_inner_loop                    
                    ld (counter),de
                    pop de
                    jp goOn
                    
                restoreMode:
                    push de
                    ld de, (counter)
                    resbox_inner_loop:
                    ld a,(de)                                
                    ld (hl),a
                    inc l                                    
                    inc de
                    djnz resbox_inner_loop                    
                    ld (counter),de
                    pop de
                    

            goOn:
    
            ld l,e                                   
            inc h                                         
            dec d
        
            jp nz, resbox_mid_loop              
    
           pop hl                                 
           pop bc                                 
    
           ld a, 32                                 
           add a, l                             
           ld l, a              
           jp nc, resbox_row_skip      

        ld a, 8              
        add a, h        
        ld h, a              

resbox_row_skip:
djnz resbox_outer_loop

END ASM
END SUB

ASM

counter:
    defb 000,000

modeflag:
    defb 000

end asm

It adds 2 new parameters: mode (1=clear, 2=save, 3=restore) and address (where the data will be saved to/restore from)

Cheers!
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)