**************************************************************************** !MAX_FIND set 14 ; --== DO NOT TOUCH ==-- !BYTE_POS set 4 ; !MATCHED set 6 ; !DATA_STRT set 8 ; !FIND_DATA set 64 ; **************************************************************************** !CODELEN set CodeEnd - CodeStart / 16 !BC set $12 !BH set $1D ***************************************************************************** ORG 0 HEADER ***************************************************************************** * Disk View V1.00 (C) Matthew Judge 1996 * ***************************************************************************** CodeStart: cs:move.w es, PSPSegment ;Save the PSP. move.w cs, bx ; cs:move.w bx, CodeSegment ;SAve the Code Segment. move.w bx, ds ;Set DS to match CS. * move.w #MEM_ERROR, dx ;Ths memory error string. move.b #$4a, ah ;Give the memory back. cs:sub.w PSPSegment, bx ;Get the code segment. add.w #!CODELEN, bx ;Add the length of the code. trap #$21 ;Give it back. bcs.s Dos_Print ;Exit if Error. * bsr.w Get_CmdLine ;Get the passed arguements. * bsr.w InitCLS ;The initial CLS. * bsr.w Save_Palette ;Save the users current palette. * bsr.w Print_Border ;Print a top and bottom border. * move.w #PALETTE, si ;Set the new palette. bsr.w Set_Palette ; * bsr.w Main ;Execute the main program. * eor.b ah, ah ;Restore the previous video mode. cs:move.b OldVideoMode, al ;The saved video mode. trap #$10 ;Call BIOS. * push,w dx move.w #SPALETTE, si ;Restore the old palette. bsr.w Set_Palette ; pop.w dx ***************************************************************************** Dos_Print: cmp.w #0, dx ;Do we print a message? beq.s Prog_Exit ;No. move.b #9, ah trap #$21 ***************************************************************************** Prog_Exit: move.b #$4c, ah ; trap #$21 ***************************************************************************** Get_CmdLine: push ds push es *-+-* cs:move.w PSPSegment, ds ;Set the DS. cs:move.w CodeSegment, es ;Set the ES. *-+-* move.w #$81, si ;Where to get the data from. move.w #CmdLine, di ;Where to store it to. move.w #Arguements, bx ;Where to store the pointers. eor.b ah, ah ;Set the flag as nothing read. *-+-* CmdLine_Loop: lods.b ;Get the next character. cmp.b #$0D, al ;The end of the line? beq.s CmdLine_Exit ;Quit if true. cmp.b #$20, al ;A space perhaps? bne.s CmdLine_Next ;No. cmp.b #0, ah ;Have we Flagged a word end? beq.s CmdLine_Loop ;Move on... *-* not.b ah ;Swap the Word Flag. move.b #$24, al ; bra.s Save_Char ; CmdLine_Next: cmp.b #0, ah ;A new word? bne.s Save_Char ;No. Start_Word: not.b ah ;Flag as NOT new word. cs:move.w di, (bx) ;Save the pointer. add.w #2, bx ;Move next. Save_Char: stos.b ;Store the character. bra.s CmdLine_Loop ;Get the next character. CmdLine_Exit: cs:move.b #$24, (di) ;End the last word. *-+-* pop es pop ds rts ***************************************************************************** Save_Palette: push cs ; pop es ;Set the segment register. move.w #SPALETTE, di :Where to save the data. move.w #6*3, cx ;The count. eor.b al, al ;The first colour to save. bsr.w _Load_Palette move.w #3, cx ; move.b #20, al ;The odd one. bsr.w _Load_Palette move.w #3, cx ; move.b #7, al ; bsr.w _Load_Palette ; move.w #7*3, cx ;The count. move.b #56, al ;The save position. _Load_Palette: move.w #$3c7, dx ;The hardware address. out.b al, dx ;Tell the hardware. add.w #2, dx ;Move to the data send. _Load_Loop: rep:ins.b ;Save the palette. rts ***************************************************************************** Print_Border: push.w es push.w cx cs:les TopLine, di ;Where to print move.w #40, cx ;The print count dc.b $66,$B8,$20,!BC,$20,!BC ;Set AX with our fill colour. repne:stos.l ;Write to the screen cs:les BottomLine, di ;Where to print move.w #40, cx ;The print count dc.b $66,$B8,$20,!BC,$20,!BC ;Set AX with our fill colour. repne:stos.l ;Write to the screen move.w #2, CursorPos ; move.w #TOP_LINE1, dx ; bsr.w Print_String move.w #114, CursorPos ; move.w #TOP_LINE2, dx ; bsr.w Print_String ; move.w #$F40, CursorPos ; move.w #BOT_LINE, dx ; bsr.w Print_String ; pop.w cx pop.w es rts ***************************************************************************** InitCLS: move.b #$0F, ah ;Get current video state. trap #$10 ;Call BIOS. *-* cs:move.b ah, OldColumns ;Save the columns. cs:move.b al, OldVideoMode ;Save the video mode. cs:move.b bh, OldDispPage ;Save the old display page. *-* move.w #$0003, ax ;Set the video mode. trap #$10 ;Call BIOS. *-* move.b #$02, ah ;Set cursor function. cs:move.b OldDispPage, bh ;The display page to use. move.w #$1000, dx ;The Row / Column. trap #$10 ;Call BIOS. CLS: push.w es push.w cx cs:les ScreenHome, di ;Where to start the CLS. cs:move.w ScreenSize, cx ; dc.b $66,$B8,$20,$0B,$20,$0B ;Set AX with our fill colour. dc.b $66,$F2,$AB ;Repeat not equal. pop.w cx pop.w es rts ***************************************************************************** Set_Palette: push cs ;Set the segment. pop ds ; _Set2: move.w #6*3, cx ;The count. eor.b al, al ;The start position. bsr.w _Send_Palette :Set the palette. move.w #3, cx ; move.b #20, al ;The odd one. bsr.w _Send_Palette ;Set it. move.w #3, cx ; move.b #7, al ; bsr.w _Send_Palette ; move.w #7*3, cx ;The new Count. move.b #56, al ;The new position. _Send_Palette: cli ;Disable interrupts. move.w #$3c8, dx ;The hardware address. out.b dx, al ;Send the mode data. inc.w dx rep:outs.b sti rts ***************************************************************************** * A Printing Binary to Hex converter:- * * AH = Colour / Character attributes * * BX = Binary to convert to Ascii Hex * * CL = Count of bytes (1 to 4) * * ES:DI = The screen address to print to * ***************************************************************************** Print_Hex: push.w cx ; asl.b #2, cl ; We are printing backwards:- dc.b $66 ror.w cl, bx ; to the front of the queue. pop.w cx ; Print_Hex_lp: dc.b $66 rol.w #4, bx ; Move to the first nibble. move.b bl, al ; and.b #$f, al ; Mask it off. add.b #$30, al ; cmp.b #$39, al ; ble.s Print_Char ; add.b #7, al ; Print_Char: stos.w ; Print the hex character. dec.b cl ; Decrement the count. bne.s Print_Hex_lp ; Loop again if not zero. rts ***************************************************************************** * DS:DX = The string to print. * * Destroys AX. * ***************************************************************************** Print_String: push.w bx push.w dx push.w di push.w si push.w es *-+-* move.w #160, bx ;Bytes per line. move.w dx, si ;Where to print from. cs:les CursorPos, di ;Where to print to. Print_Loop: lods.b ;Get the first character. cmp.b #32, al ;Greater than a space? bge.s _Print_It ;Yeh, sure is.. *-+-* cmp.b #0, al ;Do we quit here? beq.s _Print_Exit ;Leave all this behind us. *-+-* cmp.b #10, al ;Line feed? bne.s _Check_CR ;Nope, sure ain't. add.w #$A0, di ;Do a line feed. bra.s Print_Loop ;Go again... _Check_CR: cmp.b #13, al ;Carriage return, perhaps? bne.s _Check_Col ;Get 'outa here. push.w ax ;Save AX. move.w di, ax ;You know the score (Wish I did). xor.w dx, dx ;Clear DX. div.w bx ;Stupid System!! asr.w #8,ax ;Position the remainder. sub.w dx, di ;Intel / Microshit monopoly combination! cs:add.w WinX, di pop.w ax ;Restore AX. bra.s Print_Loop ;Go again... _Check_Col: cmp.b #01, al ;Change of colour? bne.s _Print_It ;Nay. lods.b ;Yea, so merrily load the next colour. asl.w #8, ax ;Set the colour. bra.s Print_Loop _Print_It: stos.w :Send it to the screen. bra.s Print_Loop ;Not again... *-+-* _Print_Exit: cs:move.w di, CursorPos ;Save the cursor position. pop.w es pop.w si pop.w di pop.w dx pop.w bx rts ***************************************************************************** * CL -> 0 = Just draw the box and string. * * CL -> 1 = Draw the box and string and wait for any key. * * CL -> 2 = Draw the box and string and wait for Yes or No. * * DX = The string to print. * ***************************************************************************** DrawInfoBox: push.w cx ;Save the get mode. eor.w cx, cx ;Set CX to our initial width. move.w #1, bx ;Set BX to our initial depth. move.w dx, di ;Move the string to our work area. Info_Loop: cs:move.b (di), al ;Get the current byte. inc.w di ;Move on one. *-* cmp.b #0, al ;Are we at the end of the string? beq.s Length_Found ;Yes, so quit. cmp.b #1, al ;Change of colour within? bne.s _Check_A ; inc.w di ;Move on another one. bra.s Info_Loop ;Loop... _Check_A: cmp.b #10, al ;A Line Feed perhaps? bne.s _Check_B ; inc.w bx ;Increment the line count. bra.s Info_Loop ;Loop once more. _Check_B: cmp.b #13, al ;A carriage? bne.s _Just_A_Char ;No... cmp.b ch, cl ;Check which is the greater. blt.s _Clear_CL asl.w #8, cx ;Set this as the widest line. _Clear_CL: eor.b cl, cl ;Start again. bra.s Info_Loop _Just_A_Char: inc.w cx ;No, increment the count... bra.s Info_Loop ;Search next. Length_Found: push.w dx ;Save the string. cmp.b ch, cl ;Get the longest line. bgt.s _Line_OK ; asr.w #8, cx ;Get the longest line length. _Line_OK: and.w #$00FF, cx ;Mask off the relevant bits. add.w #2, cx ;Create a space either side. move.b #!BC, ah ;Set the colour. bsr.w DrawBox ;Draw the box. cs:move.w dx, CursorPos ;Set the print position. pop.w dx ;Pop the string. bsr.w Print_String ;Print the string. pop.w cx ;Pop the key mode. or.b cl ,cl ;Check just quit. beq.s InfoExit InfoWait: bsr.w Get_KeyStroke ;Get a keystroke. or.w ax, ax ;Check for zero entry. beq.s InfoWait cmp.b #1, cl ;Check for any key. beq.s InfoExit ;Yep. and.b #$DF, al ;Mask off the bits. cmp.b #'Y', al ; beq.s InfoExit cmp.b #'N', al bne.s InfoWait InfoExit: cs:move.w #0, WinX :Reset the X start position. rts ***************************************************************************** * BX = Depth * * CX = Width * * DX = Returns the first byte inside the box * ***************************************************************************** DrawBox: push.w ax ;Save AX - the colour! push.w cx ;Save CX. move.w #24, ax ;This little lot will - sub.w bx, ax ;attempt to centre the box. shr.w #1, ax ; move.w ax, di ; shl.w #2, di ; cs:move.w di, WinY :Save the Y start position. add.w ax, di ; shl.w #5, di ; cs:move.b OldColumns, ax ;How many columns on this screen. sub.w cx, ax ; and.w #$FFFE,ax ;Keep it crisp and even. add.w ax, di ; add.w #4, ax ; cs:move.w ax, WinX :Save the window X position. pop.w cx ;Restore CX. pop.w ax ; DrawImdBox: push.w es ;Save ES. cs:move.w CursorPos+2, es ;Set the screen. *-* push.w di ;Save the screen position. move.b #201, al ;The top left corner. stos.w ;Print it. move.w di, dx ; add.w #162, dx ;The first byte inside the box. move.b #205, al ;An horizontal line. push.w cx ;The Width. repne ;Print a line. stos.w ;Print it. pop.w cx ;Restore the width. move.b #187, al ;Top right corner. stos.w ;Print it. _Line_Loop: pop.w di ;Pop it. lea 160(di), di ;Move to the next line. push.w di ;Save it. move.b #186, al ;Load AX. stos.w ;Print a vertical line. push.w cx :Save the width, move.b #32, al :Print Spaces. repne ;Repeat... stos.w ;Print a load of filling spaces. pop.w cx ;Restore CX. move.b #186, al ;Pre-load AX. stos.w ;Print right vertical line. dec.w bx ;Move down a line bne.s _Line_Loop pop di ; lea 160(di), di ;Move next... move.b #200, al ;The bottom left corner. stos.w ;Print it. move.b #205, al ;An horizontal line. repne ;Print a line. stos.w ;Print it. move.b #188, al ;The bottom right corner. stos.w ;Print it. *-* pop.w es ;Restore ES. rts ***************************************************************************** Wait_Trace: push dx move.w #$3da, dx ;Wait for the vertical trace. _wait_lp1: in.b dx, a ;Wait for retrace to start. and.b #8, a ;Quicker than 'test' on older machines. bne.s _wait_lp1 ;Twiddle your thumbs awhile. _wait_lp2: in.b dx, a and.b #8, a beq.s _wait_lp2 ;Wait for retrace to finish. pop dx rts ***************************************************************************** Get_KeyStroke: push si push di push ds push bx cs:lds KeyMem, si eor.w ax, ax move.w (si), di cmp.w 2(si), di ;Check if a key was pressed. beq.s Exit_KeyStroke ;Definitely, Maybe not. move.w (di), bx ;Get the KeyStroke data. lea 2(di), di ;Reset the header. move.w di, (si) ; cmp.w #$3c, di ; ble.s Print_KeyStroke ; move.w #$1e, (si) ; Print_KeyStroke: push bx ; push cx ; cs:les KeyPrint, di ; move.b #!BC, ah ; move.b #4, cl ; bsr.w Print_Hex ; pop cx ; pop ax ; Exit_KeyStroke: pop bx pop ds pop di pop si rts *-+-* KeyMem dc.w $001a, $0040 KeyPrint dc.w $0F96, $B800 ***************************************************************************** PALETTE dc.b $00,$00,$00 ;COLOUR0 dc.b $0E,$12,$12 ;COLOUR1 dc.b $12,$30,$25 ;COLOUR2 dc.b $15,$25,$30 ;COLOUR3 dc.b $10,$37,$10 ;COLOUR4 dc.b $05,$20,$05 ;COLOUR5 dc.b $2D,$2D,$00 ;COLOUR6 dc.b $29,$20,$02 ;COLOUR7 dc.b $27,$15,$00 ;COLOUR8 dc.b $32,$14,$04 ;COLOUR9 dc.b $2B,$22,$37 ;COLOUR10 dc.b $2B,$08,$15 ;COLOUR11 dc.b $00,$25,$35 ;COLOUR12 dc.b $34,$34,$34 ;COLOUR13 dc.b $37,$12,$0E ;COLOUR14 ***************************************************************************** SPALETTE ds.b 15*3 ;Saved colour data. OldDispPage dc.b 1 OldVideoMode dc.b 1 OldColumns dc.b 1 *-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-* ScreenSize dc.w 40*23 TopLine dc.w $0000,$B800 ;Where to print the top bar BottomLine dc.w $0F00,$B800 ;Where to print the bottom bar. ScreenHome dc.w $00A0,$B800 ;The first line for output. CursorPos dc.w $00A0,$B800 ;The current cursor position. *---------------------------------------------------------------------------* WinX dc.w 0 WinY dc.w 0 *---------------------------------------------------------------------------* PSPSegment dc.w 1 CodeSegment dc.w 1 TOP_LINE1 dc.b 1,$19,"File Patcher Version 1.1",0 TOP_LINE2 dc.b 1,$1C,"- Holiday Lights V2.0 -",0 BOT_LINE dc.b 1,$13,"--== MYSTIQUE ==--",0 MEM_ERROR dc.b "Error Freeing Memory...$" OPENING dc.b 13,10,1,$02,"Unlocking: ",1,$07,0 DONE dc.b 1,$03," Complete",0 OPEN_ERROR dc.b 1,$0B," Failed To Open",0 FAILED dc.b 1,$05," Nothing To Do",0 DISCLAIMER dc.b 1,$1E,10," *** DISCLAIMER ***",13,10,10 dc.b 1,$13," If you find this software useful then",13,10 dc.b 1,$13,"please register and buy the full version.",13,10,10 dc.b 1,$12," Supplied in full " dc.b 1,$14,$54,1,$15,$65,1,$1E,$63,1,$16,$68,1,$1D,$6E,1,$18,$6F,1,$12,"-Colour",13,10, dc.b 1,$12," and compiled with ",1,$16,"GEMA",0 BYE dc.b "Bye...$" Arguements ds.w 20 CmdLine ds.b 256 ***************************************************************************** * The program is to go here. ***************************************************************************** Main: move.b #1, cl move.w #Info, dx bsr.w DrawInfoBox bsr.w CLS * move.w #FILELIST, si ;The list of files to hack move.w #$A0, CursorPos ;Start at the top hack_loop: move.w #Buffer, di ;Our temporary buffer. lea SearchData, bx ;Our Searh Data... eor.l a, a ;Clear EAX _Clr_Loop: move.l a, !BYTE_POS(bx) ;Clear the slate... lea !FIND_DATA(bx), bx ;Move next. cmp.w #0, (bx) ;Cleared all? bne.s _Clr_Loop * move.w #OPENING, dx ;Print a message. bsr.w Print_String * move.w (si), dx ; bsr.w Print_String * move.w #$4301, ax ;Set as NOT read only! xor.w cx,cx ;Set No Flags move.w (si), dx ;The filename trap #$21 ; * move.w #$3D02, ax ;Open file for read/write. move.w (si), dx ;Hopefully a pointer to the file name. trap #$21 bcc.s File_Ok ;Exit if error. * move.w #OPEN_ERROR, dx ;Error on open bsr.w Print_String ;Let 'em know bra.w File_Next * File_Ok: move.b #0, Modified ;Set not modified move.w ax, bx ;Put it where it is needed push.w bx ;Save the handle [0] xor.l a, a ;Set the file position as zero move.l a, FilePos ;Save it * Read_Loop: move.b #$3F, ah ;The mode move.w #512, cx ; move.w di, dx ;Where to store the data. trap #$21 ;Go get 'em. * or.w ax, ax ;Zero bytes read? beq.w Write_File ;All done. * push.w bx ;Save the handle [again] [1] push.w si ;Save the current file name. [2] * xor.l b, b ;Clear our buffer count _Comp_Lp_1: lea SearchData, si ;Our Searh Data... _Comp_Lp_2: push.w si ;Save the Search data position [3] move.w !BYTE_POS(si), cx ;The current position to check move.w (si), si ;Where to check. add.w cx, si ;Move to it. cmp.w #$FFFF, (si) ;Do we care what this byte is? beq.s _Matched ;No cmp.w #$FFFE, (si) ;The end of the comparison bytes? bne.s _Comp_Byte * pop.w si ;Pop [3] move.w #0, !BYTE_POS(si) ;Reset the string position. inc.w !MATCHED(si) ;Move to the next save position. move.b #1, Modified bra.s _Comp_Lp_2 ;Compare again. * _Comp_Byte: move.b (bx, di), cl ;Get the comparison data. cmp.b (si), cl ;Compare. bne.w _No_Match ; * _Matched: pop.w si ;Restore SI [3] cmp.w #0, !BYTE_POS(si) ;First Byte? bne.s _No_Save ;Nope push.w si ; [4] push.l b ; [5] add.l FilePos, b ; move.w !MATCHED(si), cx ;Get the current save position. rol.w #2, cx ; add.w cx, si ; move.l b, !DATA_STRT(si) ; pop.l b ; [5] pop.w si ; [4] _No_Save: add.w #2, !BYTE_POS(si) ;Move to the next byte. bra.s _Next_String * _No_Match: pop.w si ;Restore the search pos. [3] move.w #0, !BYTE_POS(si) ;Clear the Current byte _Next_String: lea !FIND_DATA(si), si ;Move next cmp.w #0, (si) ;The End? bne.w _Comp_Lp_2 ;Nope * inc.w bx ;Move to the next byte in the buffer. cmp.w ax, bx ; bne.w _Comp_Lp_1 ; * add.l b, FilePos ;Save how far we have read. pop.w si ;Restore the file name [2] pop.w bx ;Restore the handle [1] bra.w Read_Loop ;Go again. **************** Write_File: push.w si ;Save the file name. [1] dc.b $90,$90,$90 * lea SearchData, si ;Our Searh Data... _Write_Loop: cmp.w #0, !MATCHED(si) ;Did we match any of this string? beq.s _Check_Next ;Nope * push.w bx ;Save the handle. dec.w !MATCHED(si) ;Move Next move.w !MATCHED(si), bx ; rol.w #2, bx ;Multiply by 4 push.l !DATA_STRT(bx,si) ;Get the data position. pop.w dx ; pop.w cx ; pop.w bx ;Restore the handle. move.w #$4200, ax ; trap #$21 ; * move.w 2(si), di ;Where to write from... move.w #1, cx ;Just the one... bra.s _W_Start _W_Lp2: lea 2(di), di ;Move next... _W_Start: cmp.w #$FFFF, (di) ;Do we care about this byte? beq.s _Move_Next ;no cmp.w #$FFFE, (di) ;At the end? beq.s _Write_Loop ;Yep * move.w di, dx ; move.b #$40, ah ; trap #$21 ;Write it bra.s _W_Lp2 * _Move_Next: lea Buffer, dx ;The buffer move.b #$3F, ah ;Read one... trap #$21 ;Get it... bra.s _W_Lp2 * _Check_Next: lea !FIND_DATA(si), si ;Move next. cmp.w #0, (si) ;Cleared all? bne.s _Write_Loop ;Go again. * pop.w si ;Restore the file name.[1] pop.w bx ;Restore the Handle [0] move.b #$3E, ah ;Close file trap #$21 * move.w #FAILED, dx ; cmp.b #0, Modified ; beq.s _Failed ; move.w #DONE, dx ;All ok _Failed: bsr.w Print_String * File_Next: lea 2(si), si ;Move next. cmp.w #0, (si) ;All done? bne.w hack_loop ;No * move.b #1, cl bsr.w InfoWait move.w #DISCLAIMER, dx bsr.w DrawInfoBox * hack_end: move.w #BYE, dx ;The Goodbye message. rts ***************************************************************************** DATA ***************************************************************************** FILELIST dc.w A,0 A dc.b "lights95.exe",0 SearchData dc.w SD1,RD1,0,0 ds.w !MAX_FIND*2 dc.w SD2,RD2,0,0 ds.w !MAX_FIND*2 dc.w SD3,RD3,0,0 ds.w !MAX_FIND*2 dc.w 0 ******************* * 16 Bit Versions * ******************* SD1 dc.w $0083,$003D,$00DC,$0011,$0042,$0000,$0000,$0075,$FFFE RD1 dc.w $FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$00EB,$FFFE SD2 dc.w $0083,$003D,$00DC,$0011,$0042,$0000,$0000,$0074,$FFFE RD2 dc.w $FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$00EB,$FFFE SD3 dc.w $0083,$003D,$00DC,$0011,$0042,$0000,$0000,$000F,$FFFE RD3 dc.w $FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$0090,$00E9,$FFFE ******************* * Information * ******************* Info dc.b 1,$1F," patching Holiday Lights version 2.0. ",13,10,10 dc.b 1,$16," ",13,10 dc.b 1,$13," Cracked in 3 hours!",13,10,10 dc.b 1,$12," ",0 ***************************************************************************** * This must be the last statements * ***************************************************************************** Modified ds.b 1 FilePos ds.w 2 Buffer ds.b 512 stack ds.b 256 STACK CodeEnd: *****************************************************************************