; I tried to add comments to the source for your understanding, but since I don't ; want any super amateurs reading it (like me), the comments only allow you to know what I'm ; telling the CPU to do, not how the code runs. This particular file doesn't have many comments. :) #include "ti86asm.inc" tempboard .equ $9000 ;<---this is VERY important .org $d748 nop jp ProgStart .dw 0 .dw ShellTitle ShellTitle: .db "Chessmaster 86",0 ProgStart: ld hl, savevar-1 ;load save info rst 20h rst 10h jr c, skipstuff ;if var doesn't exist, then no saving ld a,b ex de,hl call _ahl_plus_2_pg3 call _set_abs_src_addr ld a,1 ld hl,$0100 call _set_abs_dest_addr xor a ld hl, 79 call _set_mm_num_bytes call _mm_ldir call _ram_page_1 ld hl, $8100 ld de, Board ld bc, 79 ldir skipstuff: call loadgreyscale ld hl, tileData ;title screen ld de, $fc00 ld bc, 1024 ldir ld hl, tileData+1024 ld de, $ca00 ld bc, 1024 ldir call pause call _RAM_PAGE_1 ;need the extra space at $8100 call OptionScreen Startgame: Call ClearScreen ld a, (curturn) cp 1 jr z, skipthisstuffdude ld a, (cpucolor) cp 2 jr z, cpuiswhite jr chessloop skipthisstuffdude: ld a, (cpucolor) cp 1 jr z, cpuiswhite chessloop: ld a, (players) cp 3 jr z, twocpu call getlegalmoves chessloop2: call drawboard call announcestuff ;check for and announce check, checkmate, or stalemate call selectpiece cp 255 jr z, exitstuff ;exit ld hl, (selposx) ld (tempposx), hl call drawselector call selectpiece cp 255 jr z, exitstuff ;exit call getboardpos push de ld bc, (selposx) ld hl, (tempposx) ld (selposx), hl push bc call getboardpos pop hl ld (selposx), hl push de call drawselector pop de pop hl ld a, (de) cp (hl) jr z, chessloop2 push hl call isthismovelegal ld hl, (selposx) ld (nxtglmx), hl pop hl or a jr z, chessloop2 call executemove call addscore ld a, (curturn) xor 1 ld (curturn), a ld hl, (moves) inc hl ld (moves), hl cpuiswhite: ld a, (players) cp 2 jr z, chessloop twocpu: call drawboard call announcestuff call getaimove call addscore ld a, (curturn) xor 1 ld (curturn), a ld hl, (moves) inc hl ld (moves), hl jp chessloop exitstuff: call closegrey ld hl, savevar-1 ;save info back into calc rst 20h rst 10h ret c ld a,b ex de,hl call _ahl_plus_2_pg3 call _set_abs_dest_addr xor a ld hl, Board call _set_abs_src_addr ld hl, 79 xor a call _set_mm_num_bytes jp _mm_ldir executemove: ld a, (hl) ld b, a ld a, (de) ld (hl), a cp 7 call z, checkforwhiteprogression cp 1 call z, checkforblackprogression xor a ld (de), a ret checkforwhiteprogression: ld a, (nxtglmy) or a jr nz, noprogression ld a, 12 ld (hl), a ret noprogression xor a ret checkforblackprogression: ld a, (nxtglmy) cp 7 ret nz ld a, 6 ld (hl), a ret whiteturn: ld hl, whitestring ld de, $1043 jp drawstring blackturn: ld hl, blackstring ld de, $1043 jp drawstring addscore: ld a, b or a ret z cp 7 jr c, skipsub6 sub 6 skipsub6: ld b, 1 cp 2 call nc, add2 cp 4 call nc, add2 cp 6 call z, ld9 ld hl, blackscore ld a, (curturn) or a call z, addwhitescore ld a, (hl) add a, b ld (hl), a ret addwhitescore dec hl ret add2: inc b inc b ret ld9: ld b, 9 ret #include chessgfx.asm #include subroutes.asm #include greyscale.asm #include chessai.asm #include legalmove.asm #include title.asm #include options.asm announcestuff: call getlegalmoves ld hl, blankstring ld de, $1643 call drawstring call copyboard2 call checkforcheck or a jr nz, checkstalemate ld hl, checkstring ld de, $1643 call drawstring ld a, ($8100) cp 255 ret nz ld hl, checkmatestring finishupend: ld de, $1643 call drawstring call pause pop hl call newgameload jp StartGame checkstalemate: ld a, ($8100) cp 255 ret nz ld hl, stalestring jr finishupend Board .db 4, 3, 2, 6, 5, 2, 3, 4 .db 1, 1, 1, 1, 1, 1, 1, 1 .db 0, 0, 0, 0, 0, 0, 0, 0 .db 0, 0, 0, 0, 0, 0, 0, 0 .db 0, 0, 0, 0, 0, 0, 0, 0 .db 0, 0, 0, 0, 0, 0, 0, 0 .db 7, 7, 7, 7, 7, 7, 7, 7 .db 10, 9, 8, 12, 11, 8, 9, 10 tempposx .db 0 tempposy .db 0 curturn .db 0 moves .dw 0 whitescore .db 0 blackscore .db 0 difficulty .db 2 players .db 1 cpucolor .db 1 cpupriority .db 2 graphics .db 3 showthinking .db 1 selposx .db 4 selposy .db 4 whitestring: .text "White" blackstring: .text "Black" Checkstring: .text "Check!" blankstring: .text " " Checkmatestring: .text "Checkmate!" stalestring: .text "Stalemate..." nodesstring: .text "Nodes:" movesstring: .text "Moves:" Wscorestring: .text "W Score:" BScorestring: .text "B Score:" Author1: .text "By: T. Williamson" piecetxt: .text " " .text " Pawn" .text " Bishop" .text "Knight" .text " Rook" .text " King" .text " Queen" savevar: .db 6, "CMsave" NewGame: .db 4, 3, 2, 6, 5, 2, 3, 4 .db 1, 1, 1, 1, 1, 1, 1, 1 .db 0, 0, 0, 0, 0, 0, 0, 0 .db 0, 0, 0, 0, 0, 0, 0, 0 .db 0, 0, 0, 0, 0, 0, 0, 0 .db 0, 0, 0, 0, 0, 0, 0, 0 .db 7, 7, 7, 7, 7, 7, 7, 7 .db 10, 9, 8, 12, 11, 8, 9, 10 .end