-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRTCpatch.a80
279 lines (253 loc) · 4.84 KB
/
RTCpatch.a80
1
;RTC PATCH for MB02+ by SHREK;dissassembled on 10th of Jan,2010 by HOOD;rewritten by Hood on 11th of Jan,2010.;correct year input from RTC by Hood;no more colission withPIT if in same page;wanna relocate the patch address??;just change BSDOSJP value,and that's it.;principle:in dos on 5760 is BLOK1,it calls 15392,where is BLOK2;in BLOK2 is OUT that pages to page with patch.After OUT comes;JP(BLOK4-on BL21-4) to patch(BLOK3-on BSDOSJP).BLOK4 retuns;with JP to BL21-4,where is OUT back TO dos,and writes time&date;***** HOW TO WORK WITH YEAR AND RTC *****;1)From RTC chip to file header(s. Y_1900); - take RTC number (00-99); - if >79,substract 80; - if not,add 20; - make the result a 7bit number;;2)From file header to display year;(under spec.:1980+7bit number=year); - take 7bit number; - if >19,substract 20; - if not,add 80; - display results ORG #8000BSDOSJP EQU 15100;placement of the patchRTC EQU 3DOS EQU 97PAT_PAG EQU 98ROM_E EQU 96PORT EQU 23;installation routineGO DI LD A,DOS OUT (PORT),A LD HL,BLOK1 LD DE,5760 LD BC,BLOK1_LEN LDIR LD HL,BLOK2 LD DE,15392 LD BC,BLOK2_LEN LDIR LD A,PAT_PAG OUT (PORT),A LD HL,BLOK4 LD DE,BL21-4 LD BC,BLOK4_LEN LDIR LD DE,BSDOSJP LD BC,BLOK3_LEN LDIR LD A,ROM_E OUT (PORT),A EI RET ;originally here was 9xNOPBLOK1 CALL 15392BLOK1_LEN EQU $-BLOK1BLOK2 DISP 15392;work address PUSH AF LD (BL21+1),SP LD SP,15858 LD (BL22+1),DE LD (BL23+1),BC LD A,PAT_PAG OUT (PORT),ABL21 LD SP,0 POP AF LD (IX+#01),E LD (IX+#02),D LD (IX+#03),C LD (IX+#04),B LD HL,128BL22 LD DE,0BL23 LD BC,0 RET ENT BLOK2_LEN EQU $-BLOK2BLOK4 DISP BL21-4 LD A,DOS OUT (PORT),A JP BSDOSJP ENT BLOK4_LEN EQU $-BLOK4BLOK3 DISP BSDOSJP;work address CALL RTCINI JR Z,JP2JP1 LD HL,128 LD DE,0 LD BC,0 JP BL21-4JP2 LD HL,BUFFER CALL RDRTC JR NZ,JP1 LD HL,BUFFER CALL JP3 RR A LD (VAR1),A LD HL,BUFFER+2 CALL JP3 LD B,#00 OR A RLA RL B RLA RL B RLA RL B RLA RL B RLA RL B LD C,A LD A,(VAR1) OR C LD (VAR1),A LD A,B LD (VAR2),A LD HL,BUFFER+4 CALL JP3 RLA RLA RLA LD B,A LD A,(VAR2) OR B LD (VAR2),A LD HL,BUFFER+6 CALL JP3 LD (VAR3),A LD HL,BUFFER+8 CALL JP3 LD B,#00 OR A RLA RL B RLA RL B RLA RL B RLA RL B RLA RL B LD C,A LD A,(VAR3) OR C LD (VAR3),A LD A,B LD (VAR4),A LD HL,BUFFER+10 CALL JP3 CP 80 JNC Y_1900 ADD A,20 JR JP4Y_1900 SUB 80JP4 RLA LD C,A LD A,(VAR4) OR C LD (VAR4),A LD HL,128 LD DE,(VAR1) LD BC,(VAR3) JP BL21-4JP3 INC HL LD A,(HL) ADD A,A LD B,A ADD A,A ADD A,A ADD A,B LD C,A DEC HL LD A,(HL) ADD A,C RET BUFFER DS 13;RTC routinesRTCINI LD BC,#0E00+RTC LD E,#50RTCII1 OUT (C),E IN A,(C) LD D,A AND #0F OR #50 XOR E RET NZ INC E LD A,E AND #0F JR NZ,RTCII1 INC B LD A,#04 OUT (C),A DEC B LD A,#06 OUT (C),A DEC B XOR A OUT (C),A RET ;test if time/date was changedRTCTST LD BC,#0D00+RTC IN E,(C) BIT 2,E RET Z LD E,#02 OUT (C),E RET ;read RTCRDRTC LD E,#10 LD (RTCRR1+1),HLRTCRR1 LD HL,#5555 LD BC,#0D00+RTC XOR A OUT (C),A LD B,ARTCRR2 IN A,(C) AND #0F LD (HL),A INC HL INC B LD A,B CP #0D JR C,RTCRR2 IN A,(C) BIT 2,A RET Z DEC E JR NZ,RTCRR1 OR C RET DB 0VAR1 DB 0VAR2 DB 0VAR3 DB 0VAR4 DB 0 ENT BLOK3_LEN EQU $-BLOK3TOT_LEN EQU $-GOObjTabDB "rtc_pP98CDW GO;where to start with SAVEDW TOT_LEN;len of SAVEDB 1;pageDW GO;starting address in file header NOP ORG $ INCLUDE "SAVEOBJ*"DISPLAY "Length of RTC PATCH code:",/D,TOT_LEN