TITLE "mp5/box.a by Douglas Jones" ; Dec 1, 2005 USE "hawk.macs" USE "monitor.h" USE "boxortext.h" INT BOXRENDER ; linkage to code in mp3test.o EXT PLOTROW PPLOTROW: W PLOTROW ; private fields specific to box objects COORDS = 8 ; X,Y coordinate pair SIZE = 16 ; X,Y dimension pair SUBLIST = 24 ; list of sub-objects SUBTITLE "boxrender written new for MP5" ; -------------------------------------------- RETAD = 0 SELF = 4 ; pointer to object being rendered UPLEFT = 8 ; X,Y coordinates of upper left corner ARSIZE = 16 BOXRENDER: ; the render methods of all box or text objects expect ; R3 -- pointer to object being rendered ; R4 -- pointer to X,Y of rendering origin ; returns R3 unchanged STORES R1,R2 STORE R3,R2,SELF ; compute coordinates of upper left corner LOAD R6,R3,COORDS+X ; self.X LOAD R7,R4,X ; origin.X ADD R6,R6,R7 STORE R6,R2,UPLEFT+X ; upleft.X = self.X + origin.X LOAD R6,R3,COORDS+Y ; self.Y LOAD R7,R4,Y ; origin.Y ADD R6,R6,R7 STORE R6,R2,UPLEFT+Y ; upleft.Y = self.Y + origin.Y LOAD R3,R2,UPLEFT+X ; -- parameter x = upleft.X LOAD R4,R2,UPLEFT+Y ; -- parameter y = upleft.Y LOAD R1,R2,SELF LOAD R5,R1,SIZE+X ; -- parameter width = self.size.X LOAD R6,R1,SIZE+Y ; -- parameter height = self.size.Y ADDI R2,R2,ARSIZE JSR R1,PLOTBOX ; plotbox( x, y, width, height ) ADDI R2,R2,-ARSIZE LOAD R3,R2,SELF LOAD R3,R3,SUBLIST ; R3 = p = self.sublist BOXRENDERLP: ; for (;;) { TESTR R3 BZS BOXRENDERQ ; if (p == NULL) exit ; -- parameter p is already in place LEA R4,R2,UPLEFT ; -- parameter origin = parent upper left ADDI R2,R2,ARSIZE LOAD R1,R3,RENDER JSRS R1,R1 ; call p.render( p, origin ) ADDI R2,R2,-ARSIZE LOAD R3,R3,NEXT ; p = p->next BR BOXRENDERLP ; } BOXRENDERQ: LOAD R3,R2,SELF LOADS R1,R2 JUMPS R1 ; return SUBTITLE "plotbox, based on showitem from MP3" ; -------------------------------------------- RETAD = 0 R8SAVE = 4 R9SAVE = 8 RASAVE = 12 RBSAVE = 16 ARSIZE = 20 PLOTBOX: ; the parameter list was changed from showitem! ; expects R3 = X coordinate ; expects R4 = Y coordinate ; expects R5 = width ; expects R6 = height STORES R1,R2 STORE R8,R2,R8SAVE STORE R9,R2,R9SAVE STORE R10,R2,RASAVE STORE R11,R2,RBSAVE ; the following register usage was changed from showitem! MOVE R8,R3 ; R8 = X MOVE R9,R4 ; R9 = Y MOVE R10,R5 ; R10 = width MOVE R11,R6 ; R11 = height ; the logic of the following is unchanged except for register usage! MOVE R3,R8 ; -- parameter x = x MOVE R4,R9 ; -- parameter y = y MOVE R5,R10 ; -- parameter w = width LIS R6,'+' ; -- parameter = '+' LIS R7,'-' ; -- parameter = '-' ADDI R2,R2,ARSIZE LOAD R1,PPLOTROW JSRS R1,R1 ; plotrow( x, y, w,'+','-') ADDI R2,R2,-ARSIZE TESTR R11 BLE PLOTBOXENDIF ; if (height > 0) { PLOTBOXLP: CMPI R11,1 BLE PLOTBOXENDLP ; while (height > 1) { ADDSI R9,1 ; y = y + 1 ADDSI R11,-1 ; height = height - 1 MOVE R3,R8 ; -- parameter x = x MOVE R4,R9 ; -- parameter y = y MOVE R5,R10 ; -- parameter w = width LIS R6,'|' ; -- parameter = '|' LIS R7,' ' ; -- parameter = ' ' ADDI R2,R2,ARSIZE LOAD R1,PPLOTROW JSRS R1,R1 ; plotrow( x, y, w,'|',' ') ADDI R2,R2,-ARSIZE BR PLOTBOXLP ; } PLOTBOXENDLP: ADDSI R9,1 ; y = y + 1 MOVE R3,R8 ; -- parameter x = x MOVE R4,R9 ; -- parameter y = y MOVE R5,R10 ; -- parameter w = width LIS R6,'+' ; -- parameter = '+' LIS R7,'-' ; -- parameter = '-' ADDI R2,R2,ARSIZE LOAD R1,PPLOTROW JSRS R1,R1 ; plotrow( x, y, w,'+','-') ADDI R2,R2,-ARSIZE PLOTBOXENDIF: ; } ; the code to display the text was deleted from here LOAD R8,R2,R8SAVE LOAD R9,R2,R9SAVE LOAD R10,R2,RASAVE LOADS R1,R2 JUMPS R1 ; return END