;-----------------------------------------------------------------------; ; File Name - LOCK.A ; ; Copyright (c) 1992 Sega of America, Inc. ; ; All Rights Reserved. ; ;-----------------------------------------------------------------------; ; ; ; REVISION HISTORY: ; ; ; ; name date comments ; ; ---- ------- ----------------------------------- ; ; SFB 18DEC92 file created ; ; DWM 25MAY93 cleared d0 before reading hardware id code ; ; DWM 15JUN93 changed MsgPtr so the addresses were offsets ; ; from the label MessageData. ; ; DWM 15JUN93 changed MsgJapan per request from SOJ ; ; ; ; Genesis territory lockout. Advises the user of incompatibilities ; ; between the cartridge and the Genesis hardware. Prevents carts ; ; intended for one territory from being run on a Genesis from another ; ; territory. ; ; ; ; This code was written for use with the SNASM assembler. It can be ; ; adapted for use with other assemblers with minor modifications. See; ; LOCK.DOC for instructions on using the territory lockout code. ; ;-----------------------------------------------------------------------; CheckVDP: clr.l d0 ;must be empty for check to work properly move.b $A10001,d0 ;read hardware territory ID lsr.b #6,d0 ;get ID into range 0..3 andi.b #3,d0 lea.l CountryCodes(pc),a0 ;point to country code table move.b (a0,d0),d0 ;translate ID to a country code tst.b d0 beq TrapCheckVDP ;illegal hardware ID (tampering?) lea.l $8801F0,a0 ;point to country codes in ID block move.w #16-1,d1 ;number of bytes in country field in ID block CheckCountry: cmp.b (a0),d0 ;is this the machine's code? beq EndCheckVDP ;found it, ok to run the game addq.l #1,a0 dbra.w d1,CheckCountry ;nope, check the next one? lea.l $C00000,a4 ;VDP data port lea.l $C00004,a5 ;VDP control port move.w #$8164,(a5) ;enable display, VINT on, DMA off move.w #$8230,(a5) ;scroll A map starts at $C000 move.w #$8C81,(a5) ;40 column mode move.w #$8F02,(a5) ;autoincrement = 2 move.w #$9001,(a5) ;scroll size = 64x32 move.l #$C0020000,(a5) ;CRAM write to color #1 move.w #$0EEE,(a4) ;set color 1 to white move.l #$40000000,(a5) ;VRAM address for chars lea.l AASCIIchars(pc),a0 ;a0 -> charset for message move.w #59-1,d0 ;59 chars move.l #$10000000,d2 ;set pixel mask WriteCharSet: move.w #8-1,d6 ;8 rows per char WriteChar: move.b (a0)+,d1 ;get a row (source is 1 bit per pixel) move.l #0,d4 ;clear pixel row accumulator move.w #8-1,d5 ;8 pixels per row WritePix: rol.l #4,d2 ;rotate masks to next pixel position ror.b d1 ;check next bit in source bcc.s NextPix ;if it's 0, don't put a pixel or.l d2,d4 ;else, put a pixel NextPix: dbra.w d5,WritePix ;next pixel WritePixRow: move.l d4,(a4) ;put pixel row in VRAM dbra.w d6,WriteChar ;next row dbra.w d0,WriteCharSet ;next char move.b #8,d1 ;set row for WriteString lea.l MsgDevelopedFor(pc),a0 ;set string address for WriteString move.b (a0)+,d0 ;set column for WriteString bsr WriteString ;write it to the screen lea.l $8801F0,a1 ;point to territory ID's in ID block CheckID: cmp.b #' ',(a1) ;if this entry in ID block = ' ' beq.s CheckIDDone ; we're done lea.l MsgPtrs(pc),a2 ;point to list of message ID's & pointers CheckMsg: move.w (a2)+,d4 ;get message ID tst.b d4 ;if message ID = 0 beq.s NextID ; step to next territory ID cmp.b (a1),d4 ;else if message ID != territory ID bne.s NoPrint ; don't print this message cmpi.b #' ',1(a1) ;if this territory ID isn't the last one bne.s PrintMsg ; don't print the "&" cmpi.l #$1F0,a1 beq.s PrintMsg lea.l MsgAnd(pc),a0 ;else move.b (a0)+,d0 ; print it addq.w #1,d1 bsr WriteString PrintMsg: lea.l MessageData(pc),a0 ;set string address for WriteString add.l (a2)+,a0 ; add offset move.b (a0)+,d0 ;set column for WriteString addq.w #1,d1 ;next line bsr WriteString ;write it to the screen bra.s NextID ;check the next territory ID NoPrint: addq.l #4,a2 ;point to the next message ID and... bra.s CheckMsg ; check it NextID: addq.l #1,a1 ;point to the next territory ID and... bra.s CheckID ; check it CheckIDDone: lea.l MsgSystems(pc),a0 ;write last line of message. move.b (a0)+,d0 addq.w #1,d1 bsr WriteString TrapCheckVDP: bra.s TrapCheckVDP WriteString: move.b d1,d2 and.l #$FF,d2 swap d2 lsl.l #7,d2 move.b d0,d3 and.l #$FF,d3 swap d3 asl.l #1,d3 add.l d3,d2 add.l #$40000003,d2 move.l d2,(a5) ws01: tst.b (a0) beq.s ws99 move.b (a0)+,d2 sub.b #' ',d2 andi.w #$FF,d2 move.w d2,(a4) bra.s ws01 ws99: rts MessageData: CountryCodes: dc.b 'J',0,'UE' MsgPtrs: dc.b 0,'J' dc.l MsgJapan-MessageData dc.b 0,'U' dc.l MsgUSA-MessageData dc.b 0,'E' dc.l MsgEurope-MessageData dc.w 0 ; 0123456789012345678901234567890123456789 MsgDevelopedFor: dc.b 6, 'DEVELOPED FOR USE ONLY WITH',0 MsgAnd: dc.b 18, '&',0 MsgSystems: dc.b 15, 'SYSTEMS.',0 MsgJapan: dc.b 12, 'NTSC MEGA DRIVE',0 MsgUSA: dc.b 13, 'NTSC GENESIS',0 MsgEurope: dc.b 4, 'PAL AND FRENCH SECAM MEGA DRIVE',0 AASCIIchars: dc.l %00000000000000000000000000000000 dc.l %00000000000000000000000000000000 ;' ' dc.l %00011000000110000001100000011000 dc.l %00000000000110000001100000000000 ;! dc.l %00110110001101100100100000000000 dc.l %00000000000000000000000000000000 ;" dc.l %00010010000100100111111100010010 dc.l %01111111001001000010010000000000 ;# dc.l %00001000001111110100100000111110 dc.l %00001001011111100000100000000000 ;$ dc.l %01110001010100100111010000001000 dc.l %00010111001001010100011100000000 ;% dc.l %00011000001001000001100000101001 dc.l %01000101010001100011100100000000 ;& dc.l %00110000001100000100000000000000 dc.l %00000000000000000000000000000000 ;' dc.l %00001100000100000010000000100000 dc.l %00100000000100000000110000000000 ;( dc.l %00110000000010000000010000000100 dc.l %00000100000010000011000000000000 ;) dc.l %00000000000010000010101000011100 dc.l %00101010000010000000000000000000 ;* dc.l %00001000000010000000100001111111 dc.l %00001000000010000000100000000000 ;+ dc.l %00000000000000000000000000000000 dc.l %00000000001100000011000001000000 ;, dc.l %00000000000000000000000001111111 dc.l %00000000000000000000000000000000 ;- dc.l %00000000000000000000000000000000 dc.l %00000000001100000011000000000000 ;¥ dc.l %00000001000000100000010000001000 dc.l %00010000001000000100000000000000 ;/ dc.l %00011110001100110011001100110011 dc.l %00110011001100110001111000000000 ;0 dc.l %00011000001110000001100000011000 dc.l %00011000000110000011110000000000 ;1 dc.l %00111110011000110110001100001110 dc.l %00111000011000000111111100000000 ;2 dc.l %00111110011000110000001100011110 dc.l %00000011011000110011111000000000 ;3 dc.l %00000110000011100001111000110110 dc.l %01100110011111110000011000000000 ;4 dc.l %01111110011000000111111001100011 dc.l %00000011011000110011111000000000 ;5 dc.l %00111110011000110110000001111110 dc.l %01100011011000110011111000000000 ;6 dc.l %00111111011000110000011000000110 dc.l %00001100000011000001100000000000 ;7 dc.l %00111110011000110110001100111110 dc.l %01100011011000110011111000000000 ;8 dc.l %00111110011000110110001100111111 dc.l %00000011011000110011111000000000 ;9 dc.l %00000000000110000001100000000000 dc.l %00000000000110000001100000000000 ;: dc.l %00000000000110000001100000000000 dc.l %00000000000110000001100000100000 ;; dc.l %00000011000011000011000001000000 dc.l %00110000000011000000001100000000 ;< dc.l %00000000000000000111111100000000 dc.l %01111111000000000000000000000000 ;= dc.l %01100000000110000000011000000001 dc.l %00000110000110000110000000000000 ;> dc.l %00111110011000110000001100011110 dc.l %00011000000000000001100000000000 ;? dc.l %00111100010000100011100101001001 dc.l %01001001010010010011011000000000 ;@ dc.l %00011100000111000011011000110110 dc.l %01111111011000110110001100000000 ;A dc.l %01111110011000110110001101111110 dc.l %01100011011000110111111000000000 ;B dc.l %00111110011100110110000001100000 dc.l %01100000011100110011111000000000 ;C dc.l %01111110011000110110001101100011 dc.l %01100011011000110111111000000000 ;D dc.l %00111111001100000011000000111110 dc.l %00110000001100000011111100000000 ;E dc.l %00111111001100000011000000111110 dc.l %00110000001100000011000000000000 ;F dc.l %00111110011100110110000001100111 dc.l %01100011011100110011111000000000 ;G dc.l %01100110011001100110011001111110 dc.l %01100110011001100110011000000000 ;H dc.l %00011000000110000001100000011000 dc.l %00011000000110000001100000000000 ;I dc.l %00001100000011000000110000001100 dc.l %11001100110011000111100000000000 ;J dc.l %01100011011001100110110001111000 dc.l %01101100011001100110001100000000 ;K dc.l %01100000011000000110000001100000 dc.l %01100000011000000111111100000000 ;L dc.l %01100011011101110111111101101011 dc.l %01101011011000110110001100000000 ;M dc.l %01100011011100110111101101111111 dc.l %01101111011001110110001100000000 ;N dc.l %00111110011000110110001101100011 dc.l %01100011011000110011111000000000 ;O dc.l %01111110011000110110001101111110 dc.l %01100000011000000110000000000000 ;P dc.l %00111110011000110110001101100011 dc.l %01101111011000110011111100000000 ;Q dc.l %01111110011000110110001101111110 dc.l %01101000011001100110011100000000 ;R dc.l %00111110011000110111000000111110 dc.l %00000111011000110011111000000000 ;S dc.l %01111110000110000001100000011000 dc.l %00011000000110000001100000000000 ;T dc.l %01100110011001100110011001100110 dc.l %01100110011001100011110000000000 ;U dc.l %01100011011000110110001100110110 dc.l %00110110000111000001110000000000 ;V dc.l %01101011011010110110101101101011 dc.l %01101011011111110011011000000000 ;W dc.l %01100011011000110011011000011100 dc.l %00110110011000110110001100000000 ;X dc.l %01100110011001100110011000111100 dc.l %00011000000110000001100000000000 ;Y dc.l %01111111000001110000111000011100 dc.l %00111000011100000111111100000000 ;Z EndCheckVDP: