LIST 2 7.TXT
Here's the fully translated MediaWiki code:
********************************************************************** * * * 68000 ASSEMBLER COURSE ON ATARI ST * * * * by The Fierce Rabbit (from 44E) * * * * Listing number 2 / Course number 7 * * * ********************************************************************** * Test resolution, because if we are in high and we try to * * switch to low, bam! RESET! * MOVE.W #4,-(SP) Getrez() function number TRAP #14 Xbios call ADDQ.L #2,SP stack correction CMP.W #2,D0 high resolution? BEQ LOAD yes, so load everything now * Since we are not in high resolution, we force into low resolution * first we note by setting a flag to 1 MOVE.W #1,RESOLUTION MOVE.W #0,-(SP) low resolution MOVE.L #-1,-(SP) unchanged screen address MOVE.L #-1,-(SP) unchanged screen address MOVE.W #5,-(SP) Setscreen() function TRAP #14 X bios ADDA.L #12,SP correction * Opening of the image file LOAD MOVE.W #0,-(SP) opening in read mode MOVE.L #FILENAME_ADDRESS,-(SP) addr of the file name MOVE.W #61,-(SP) Fopen() function TRAP #1 from GEMDOS ADDQ.L #8,SP stack correction * D0 contains the Handle or a negative error number TST.W D0 compare to 0 BLT ERROR less than so error * We save the file handle MOVE.W D0,D3 * Skip the first 34 bytes of the DEGAS file * (2 header bytes, 32 for colors) MOVE.W #0,-(SP) shift from the start of file MOVE.W D3,-(SP) file handle MOVE.L #34,-(SP) number of bytes to skip MOVE.W #66,-(SP) Fseek() function TRAP #1 from GEMDOS ADDA.L #10,SP TST.W D0 test D0 BLT ERROR * Determine the screen address MOVE.W #2,-(SP) Physbase() function TRAP #14 xbios ADDQ.L #2,SP stack correction MOVE.L D0,A5 save address * Load the image directly onto the screen MOVE.L A5,-(SP) destination address MOVE.L #32000,-(SP) number of bytes to read MOVE.W D3,-(SP) file handle MOVE.W #63,-(SP) Fread() function TRAP #1 from GEMDOS ADDA.L #12,SP TST.W D0 BLT ERROR * Load the palette into our palette buffer * First reposition the file pointer MOVE.W #0,-(SP) shift from the start of file MOVE.W D3,-(SP) file handle MOVE.L #2,-(SP) number of bytes to skip MOVE.W #66,-(SP) Fseek() function TRAP #1 from GEMDOS ADDA.L #10,SP TST.W D0 test D0 BLT ERROR * Then loading MOVE.L #PALETTE_BUFFER,-(SP) destination address MOVE.L #32,-(SP) number of bytes to read MOVE.W D3,-(SP) file handle MOVE.W #63,-(SP) Fread() function TRAP #1 from GEMDOS ADDA.L #12,SP TST.W D0 BLT ERROR * Now we set this palette with Xbios (6) MOVE.L #PALETTE_BUFFER,-(SP) black palette address MOVE.W #6,-(SP) SetPalette() function TRAP #14 XBIOS ADDQ.L #6,SP * We close the file MOVE.W D3,-(SP) handle MOVE.W #62,-(SP) Fclose() function TRAP #1 from GEMDOS ADDQ.L #4,SP BRA END and we get out * In case of error we come here ERROR MOVE.L #ERROR_MESSAGE,-(SP) informs MOVE.W #9,-(SP) TRAP #1 ADDQ.L #6,SP END MOVE.W #7,-(SP) wait for a key press TRAP #1 ADDQ.L #2,SP CMP.W #0,RESOLUTION BEQ NOT_MEDIUM * Since we are in low, we force back into medium resolution MOVE.W #1,-(SP) medium resolution MOVE.L #-1,-(SP) unchanged screen address MOVE.L #-1,-(SP) unchanged screen address MOVE.W #5,-(SP) Setscreen() function TRAP #14 XBIOS ADDA.L #12,SP correction * Then we exit NOT_MEDIUM MOVE.W #0,-(SP) TRAP #1 *-------------------------------------------------------------* SECTION DATA ERROR_MESSAGE DC.B "Sorry, error with",13,10 DC.B "the file " FILENAME_ADDRESS DC.B "A:\IMAGE.PI1",0 SECTION BSS PALETTE_BUFFER DS.W 16 RESOLUTION DS.W 1
Back to ASM_Tutorial