;Calander 86z 1.1 ;By: Ahmed El-Helw ;Copyright (C) 1998 ;ahmedre@worldnet.att.net ;http://members.xoom.com/ahmedre #include "asm86.h" #include "ti86asm.inc" .org _asm_exec_ram ;------------------------ASE 1.0+ / Rascall 0.9+ Description ---------------------------- nop ;Identifies the table jp Init ;Jump to Start of Program .dw $0000 ;Version # of Table .dw Title ;Absolute pointer to program description ;---------------------------------------------------------------------------------------- Init: ld a,5 ;4 into A [Wednesday] ld (DayStart),a ;Starting Day for Month [The First was Wednesday] ld a,2 ;2 into A ld (Leap),a ;Leap Year = 5 [28 month Feb. this year, 1998] ld a,28 ;28 into A ld (FebDays),a ;A into FebDays ld a,1 ;Loads Month # into A ld (Month),a ;Loads A into Month [Starting Month December] ld hl,1998 ;Loads Year into HL ld (Year),hl ;Loads it into Year # jr Start ;Start! Start: call _clrLCD xor a ;Same as ld a,0 ld (_curCol),a ;Column of Text ld (_curRow),a ;Row for Text ld hl,TitleString ;TitleString into HL call _puts ;Send to screen! [Large Text] set 3,(iy+$05) ;Text is now white on black ld de,8*256+0 ;Loads Coordinates ld hl,BlankDay ;String into HL call PutText ;Display it! ld de,8*256+5 ;Loads Coordinates ld hl,Satday ;String into HL call PutText ;Display it! ld de,8*256+23 ;Loads Coordinates ld hl,Monday ;String into HL call PutText ;Display it! ld de,8*256+43 ;Loads Coordinates ld hl,Thuesday ;String into HL call PutText ;Display it! ld de,8*256+61 ;Loads Coordinates ld hl,Wednesday ;String into HL call PutText ;Display it! ld de,8*256+81 ;Loads Coordinates ld hl,Thuesday ;String into HL call PutText ;Display it! ld de,8*256+101 ;Loads Coordinates ld hl,Friday ;String into HL call PutText ;Display it! ld de,8*256+119 ;Loads Coordinates ld hl,Satday ;String into HL call PutText ;Display it! res 3,(iy+$05) ;Text is now black on white jp PutCal PutCal: ;Routine to Display Calander call PutMonth ;Routine to Display Month call _vputs ;Put the String on Screen call PutYear ;Display the Year ld a,(DayStart) ;Starting Day into A ld (Spot),a ;A into Spot ld a,1 ;Load 1 into a ld (Day),a ;Make Day = 1 ld (Week),a ;Make Week = 1 jr Loop ;Goto Loop Loop: ;Loop to Display the Numbers ld a,(Spot) ;Spot into A cp 1 ;Is it 1? jp z,DispSun ;Goto Display Sunday cp 2 ;Is it 2? jp z,DispMon ;Display Monday cp 3 ;Is it 3? jp z,DispTue ;Display Tuesday cp 4 ;Is it 4? jp z,DispWed ;Display Wednesday cp 5 ;Is it 5? jp z,DispThur ;Display Thursday cp 6 ;Is it 6? jp z,DispFri ;Display Friday cp 7 ;Is it 7? jp z,DispSat ;Display Saturday DispSun: call CheckWeek ;Checks week to set ld a,1 ;1 into A ld (_penCol),a ;A into Column ld a,(Day) ;Day into A call DispA ;Display A jp CheckStatus ;Checks Status of Days DispMon: call CheckWeek ;Checks week to set ld a,18 ;18 into A ld (_penCol),a ;A into Column ld a,(Day) ;Day into A call DispA ;Display A jp CheckStatus ;Checks Status of Days DispTue: call CheckWeek ;Checks week to set ld a,38 ;38 into A ld (_penCol),a ;A into Column ld a,(Day) ;Day into A call DispA ;Display A jp CheckStatus ;Checks Status of Days DispWed: call CheckWeek ;Checks week to set ld a,56 ;56 into A ld (_penCol),a ;A into Column ld a,(Day) ;Day into A call DispA ;Display A jp CheckStatus ;Checks Status of Days DispThur: call CheckWeek ;Checks week to set ld a,76 ;76 into A ld (_penCol),a ;A into Column ld a,(Day) ;Day into A call DispA ;Display A jp CheckStatus ;Checks Status of Days DispFri: call CheckWeek ;Checks week to set ld a,96 ;96 into A ld (_penCol),a ;A into Column ld a,(Day) ;Day into A call DispA ;Display A jp CheckStatus ;Checks Status of Days DispSat: call CheckWeek ;Checks week to set ld a,113 ;113 into A ld (_penCol),a ;A into Column ld a,(Day) ;Day into A call DispA ;Display A jp CheckStatus ;Checks Status of Days CheckStatus: ld a,(TotalDays) ;Total Days into A ld b,a ld a,(Day) ;Days into A sub b or a jp z,GetKeyLoop ;Goto GetKeyLoop if equal jp ContinueLoop ;Otherwise, Continue Loop ContinueLoop: ld a,(Day) ;Day into A inc a ;Increase A ld (Day),a ;Back into Day ld a,(Spot) ;Loads Spot into a inc a ;Increase it ld (Spot),a ;A into Spot cp 8 ;Is it 8 jp z,NewWeek ;Do a NewWeek jp Loop ;Redo Loop NewWeek: ld a,(Week) ;Week into A inc a ;Increase it ld (Week),a ;A back into Week ld a,1 ;1 into A [Sunday] ld (Spot),a ;A into Spot jp Loop ;Return GetKeyLoop: halt ;Save Energy call GET_KEY ;Wait for a key cp K_EXIT ;Is it Exit ? jp z,_clrLCD ;Clear Screen/Return cp K_RIGHT ;Is it Right? jp z,IncreaseMonth ;Increase the Month! cp K_LEFT jp z,DecreaseMonth cp K_UP ;Is it Up? jp z,IncreaseYear ;Increase the Year cp K_DOWN ;Is it Down? jp z,DecreaseYear ;Decrease the Year jp nz,GetKeyLoop ;No Key? Reloop! IncreaseYear: ld a,(DayStart) ;Load DayStart into A inc a ;Increase A ld (DayStart),a ;A into DayStart cp 8 ;Is it 8? call z,ResetStart ;Reset to Sunday! ld hl,(Year) ;Year into HL inc hl ;Increase it ld (Year),hl ;HL back into Year ld a,28 ;Load 28 into A ld (FebDays),a ;Febuary Days as a ld a,(Leap) ;Leap into A dec a ;Decrease it ld (Leap),a ;Load A into Leap or a ;Is it 0 ? call z,LeapYear ;Call LeapYear call ResetVars jp Start DecreaseYear: ld a,(DayStart) ;Load DayStart into A dec a ;Decrease A ld (DayStart),a ;A into DayStart cp 0 ;Is it 0? call z,ResetSaturday ;Reset to Saturday! ld hl,(Year) ;Year into HL dec hl ;Decrease it ld (Year),hl ;HL back into Year ld a,28 ;Load 28 into A ld (FebDays),a ;Febuary Days as a ld a,(Leap) ;Leap into A inc a ;Increase it ld (Leap),a ;Load A into Leap cp 8 ;Is it 8 ? call z,LeapYear ;Call LeapYear cp 4 ;Is it 4? call z,LeapYear ;Call LeapYear call ResetVars jp Start IncreaseMonth: ld a,(Spot) ;Day Spot into A inc a ;Increase ld (DayStart),a ;A into DayStart cp 8 ;Is it 8? call z,ResetStart ;Reset to Sunday! ld a,(Month) ;Month # into A inc a ;Increase it ld (Month),a ;A into Month cp 13 ;Is it 13?? call z,NewYear ;NewYear! call ResetVars jp Start ;Goto Start! [Display it!] ;------------------------------- ;|Routines to Decrease the Month ;------------------------------- DecreaseMonth: ld a,(Month) ;Checks the month.. if it is cp 3 ;March, your going to Feb jp z,GotoFeb ;If it is a 31 day month, your going to a 30 day month.. cp 5 jp z,Goto30 cp 7 jp z,Goto30 cp 11 jp z,Goto30 cp 8 ;August and July are 30 days, so special loop for them.. jp z,GotoJul cp 1 ;If it is January, your going to switch years, so another jp z,GotoDec ;special loop for that... cp 2 ;If it is February, we are dealing with a random number of jp z,GotoJan ;days, so a special loop for that as well... ld b,29 ;If not,then we are going to a 31 day month.. Loop 29x to get Dec3031Days: ;to the beginning of the month... ld a,(Spot) dec a ld (Spot),a or a call z,ResDecSat djnz Dec3031Days ld b,31 ;Then loop 31x to get to the beginning of the previous month.. Dec31Days: ld a,(Spot) dec a ld (Spot),a or a call z,ResDecSat djnz Dec31Days ld a,(Spot) ld (DayStart),a ld a,(Month) dec a ld (Month),a or a call z,OldYear call ResetVars jp Start ResDecSat: ;If spot is 0, this means that ld a,7 ;we are really on a Saturday.. ld (Spot),a ;so we make it Saturday. ret Goto30: ld b,30 Dec3130Days: ld a,(Spot) dec a ld (Spot),a or a call z,ResDecSat djnz Dec3130Days ld b,30 Dec30Days: ld a,(Spot) dec a ld (Spot),a or a call z,ResDecSat djnz Dec30Days ld a,(Spot) ld (DayStart),a ld a,(Month) dec a ld (Month),a call ResetVars jp Start GotoFeb: ld b,30 DecMarDays: ld a,(Spot) dec a ld (Spot),a or a call z,ResDecSat djnz DecMarDays ld a,(FebDays) ld b,a DecFebDays: ld a,(Spot) dec a ld (Spot),a or a call z,ResDecSat djnz DecFebDays ld a,(Spot) ld (DayStart),a ld a,(Month) dec a ld (Month),a call ResetVars jp Start GotoJul: ld b,31 DecJulDays: ld a,(Spot) dec a ld (Spot),a or a call z,ResDecSat djnz DecJulDays ld a,31 ld b,a JulDays: ld a,(Spot) dec a ld (Spot),a or a call z,ResDecSat djnz JulDays ld a,(Spot) inc a ld (DayStart),a ld a,(Month) dec a ld (Month),a call ResetVars jp Start GotoDec: ld b,30 DecJanDays: ld a,(Spot) dec a ld (Spot),a or a call z,ResDecSat djnz DecJanDays ld b,31 DecDecDays: ld a,(Spot) dec a ld (Spot),a or a call z,ResDecSat djnz DecDecDays ld a,(Spot) ld (DayStart),a ld a,12 ld (Month),a call OldYear jp Start GotoJan: ld a,(FebDays) ld b,a DecFDays: ld a,(Spot) dec a ld (Spot),a or a call z,ResDecSat djnz DecFDays ld b,31 DectoJanDays: ld a,(Spot) dec a ld (Spot),a or a call z,ResDecSat djnz DectoJanDays ld a,(Spot) inc a ld (DayStart),a ld a,(Month) dec a ld (Month),a call ResetVars jp Start OldYear: ld hl,(Year) dec hl ld (Year),hl ld a,(Leap) ;Leap into A inc a ;Increase it ld (Leap),a ;Load A into Leap cp 8 ;Is it 8 ? call z,LeapYear ;Call LeapYear cp 4 ;Is it 4? call z,LeapYear ;Call LeapYear ret ResetStart: ld a,1 ;Loads 1 into A ld (DayStart),a ;A into DayStart [Sunday] ret ;Return ResetSaturday: ld a,7 ;Loads 7 into A ld (DayStart),a ;A into DayStart [Saturday] ret ;Return NewYear: ld a,1 ;Loads 1 into A ld (Month),a ;A into Month [January] ld hl,(Year) ;Year into HL inc hl ;Increase it ld (Year),hl ;HL into Year ld a,(Leap) ;Leap into A dec a ;Decrease it ld (Leap),a ;Back into Leap cp 0 ;Is it 0? jp z,LeapYear ;LeapYear it is ld a,28 ;Loads 28 into A ld (FebDays),a ;A into FebDays ret ;return LeapYear: ;Loop to find out if the year is 100x ld hl,(Year) ;Loads Year into HL ld (TestYear),hl ;Loads HL into TestYear ld b,60 ;Loads 10 into b, starting a loop... LeapLoop: ld hl,(TestYear) ;Load the Test Year into HL ld de,0 ;We want to check if it is 0 call CP_HL_DE ;So we check... jp z,Test400x ;if it is 0, then it is 100x, so test 400x ld hl,(TestYear) ;if not, then keep going... ld de,-100 ;Load -100 into bc add hl,de ;Add it w/the year [aka TestYear-500] ld (TestYear),hl ;Loads that into Year djnz LeapLoop ;Reloops until b = 0 ;---------------Real Leap Year!-------------------- RLY: ;Real Leap Year! ld a,29 ;Loads 29 into A ld (FebDays),a ;Loads A into FebDays ld a,4 ;Loads 4 into A ld (Leap),a ;A into Leap [LeapYear] ret ;return Test400x: ld hl,(Year) ;Loads Year into HL ld (TestYear),hl ;Loads HL into TestYear ld b,60 ;Loads 10 into b, starting a loop... LeapLoop2: ld hl,(TestYear) ;Load the Test Year into HL ld de,0 ;We want to check if it is 0 call CP_HL_DE ;So we check... jp z,RLY ;if it is 0, then it is 400x, so leap year ld hl,(TestYear) ;if not, then keep going... ld de,-400 ;Load -100 into bc add hl,de ;Add it w/the year [aka TestYear-400] ld (TestYear),hl ;Loads that into Year djnz LeapLoop2 ;Reloops until b = 0 NotReal: ;Not REALLY a Leap Year... ld a,4 ;Loads 4 into A ld (Leap),a ;Reset LeapDays ret ;Return ResetVars: xor a ;Load 0 into a ld (Week),a ;A into Week ld (Day),a ;A into Day ld (Spot),a ;A into Spot ret CheckWeek: ld a,(Week) ;Loads the week into A cp 1 ;Is it 1 jp z,Week1 ;Then set Week1 Coords cp 2 ;Is it 2 jp z,Week2 ;Then set Week2 Coords cp 3 ;Is it 3 jp z,Week3 ;Then set Week3 Coords cp 4 ;Is it 4 jp z,Week4 ;Then set Week4 Coords cp 5 ;Is it 5 jp z,Week5 ;Set Week5 Coords jp nz,Week6 ;Otherwise .. Week6 Week1: ld a,15 ;Load into A ld (_penRow),a ;Set a as PenRow ret ;Return Week2: ld a,22 ;Load into A ld (_penRow),a ;Set a as PenRow ret ;Return Week3: ld a,29 ;Load into A ld (_penRow),a ;Set a as PenRow ret ;Return Week4: ld a,36 ;Load into A ld (_penRow),a ;Set a as PenRow ret ;Return Week5: ld a,43 ;Load into A ld (_penRow),a ;Set a as PenRow ret ;Return Week6: ld a,50 ;Loads into A ld (_penRow),a ;Set a as PenRow ret PutMonth: ld a,(Month) ;Loads Month # into A cp 1 ;If it is 1 jp z,Month1 ;Goto Month1 [January] cp 2 ;Is it two? jp z,Month2 ;Goto Month2 [Febuary] cp 3 ;Is it 3? jp z,Month3 ;Goto Month3 [March] cp 4 ;Is it 4 jp z,Month4 ;Goto Month 4 cp 5 ;Is it 5 jp z,Month5 ;Goto Month5 cp 6 ;Is it 6 jp z,Month6 ;Goto Month 6 cp 7 ;Is it 7 jp z,Month7 ;Goto Month7 cp 8 ;Is it 8 jp z,Month8 ;Goto Month 8 cp 9 ;Is it 9 jp z,Month9 ;Goto Month 9 cp 10 ;Is it 10 jp z,Month10 ;Goto Month10 cp 11 ;Is it 11 jp z,Month11 ;Goto Month11 jp nz,Month12 ;Otherwise, it has to be 12, so goto Month12 Month1: ;Month1 Label [January] ld a,31 ;31 into A ld (TotalDays),a ;A -> Total Days call SetText ;Put coordinates for text ld hl,January ;String into HL ret ;Return to Call Month2: ;Month2 Label [February] ld a,(FebDays) ;February Days into A ld (TotalDays),a ;A => Total Days call SetText ;Put coordinates for text ld hl,Febuary ;String into HL ret ;Return to Call Month3: ;Month3 Label [March] ld a,31 ;31 into A ld (TotalDays),a ;A -> Total Days call SetText ;Put coordinates for text ld hl,March ;String into HL ret ;Return to Call Month4: ;Month4 Label [April] ld a,30 ;30 into A ld (TotalDays),a ;A -> Total Days call SetText ;Put coordinates for text ld hl,April ;String into HL ret ;Return to Call Month5: ;Month5 Label [May] ld a,31 ;31 into A ld (TotalDays),a ;A -> Total Days call SetText ;Put coordinates for text ld hl,May ;String into HL ret ;Return to Call Month6: ;Month6 Label [June] ld a,30 ;30 into A ld (TotalDays),a ;A -> Total Days call SetText ;Put coordinates for text ld hl,June ;String into HL ret ;Return to Call Month7: ;Month7 Label [July] ld a,31 ;31 into A ld (TotalDays),a ;A -> Total Days call SetText ;Put coordinates for text ld hl,July ;String into HL ret ;Return to Call Month8: ;Month8 Label [August] ld a,31 ;31 into A ld (TotalDays),a ;A -> Total Days call SetText ;Put coordinates for text ld hl,August ;String into HL ret ;Return to Call Month9: ;Month9 Label [September] ld a,30 ;30 into A ld (TotalDays),a ;A -> Total Days call SetText ;Put coordinates for text ld hl,September ;String into HL ret ;Return to Call Month10: ;Month1 Label [October] ld a,31 ;31 into A ld (TotalDays),a ;A -> Total Days call SetText ;Put coordinates for text ld hl,October ;String into HL ret ;Return to Call Month11: ;Month11 Label [November] ld a,30 ;30 into A ld (TotalDays),a ;A -> Total Days call SetText ;Put coordinates for text ld hl,November ;String into HL ret ;Return to Call Month12: ;Month12 Label [December] ld a,31 ;31 into A ld (TotalDays),a ;A -> Total Days call SetText ;Put coordinates for text ld hl,December ;String into HL ret ;Return to Call SetText: ld hl,57*256+32 ;Set Coordinates ld (_penCol),hl ;Into PenCol ret ;Return PutYear: ld hl,57*256+80 ;Set Coordinates ld (_penCol),hl ;Into PenCol ld hl,(Year) ;Load Year # into HL call DispHL ;Display It! res 3,(iy+$05) ret PutText: ld (_penCol),de call _vputs ret ;-----------------Routine by SCaBBy----------------------- DispA: ;Routine to Display A ld l,a ;Loads A into L ld h,0 ;Loads 0 into H DispHL: ;Routine to Display HL xor a ;Sets a to 0 ld de,-1 ;Loads -1 into DE ld (_curRow),de ;De into Cursor Row call 4A33h dec hl ;Decrease HL jp _vputs ;Put it on the screen! ;--------------------------------------------------------- Title: .db "Calendar 86z - By: ARE",0 TitleString: .db " Calendar 86z ",0 BlankDay: .db " ",0 Satday: .db "S ",0 Monday: .db "M ",0 Thuesday: .db "T ",0 Wednesday: .db "W ",0 Friday: .db "F ",0 January: .db "January",0 Febuary: .db "February",0 March: .db "March",0 April: .db "April",0 May: .db "May",0 June: .db "June",0 July: .db "July",0 August: .db "August",0 September: .db "September",0 October: .db "October",0 November: .db "November",0 December: .db "December",0 ;-----------------------Variables------------------------- DayStart: .db 0 Month: .db 0 Week: .db 0 Spot: .db 0 TotalDays: .db 0 Day: .db 0 Leap: .db 0 FebDays: .db 0 Year: .db 0,0 TestYear: .db 0,0 ;--------------------------------------------------------- .end ;Tell TASM it is all over END ;Tell TASM it is all over