Как создать массив из квадратиков, по типу шахматной доски? - VB

Узнай цену своей работы

Формулировка задачи:

Здравствуйте!

Очень прошу помощи. Мечтаю слиться с Visual Basic 6.0 в одно целое, ощущать его сердцем. Не знаю, подскажите пожалуйста: как осуществить план (замысел) по созданию двумерного массива 5х5 из клеток (каждая размером 1000х1000 — квадратики). В основе лежит функция "

Shape

" из стандартного набора Visual Basic 6.0. Надо, чтобы каждая ячейка-клетка могла становиться активной.

Заранее прошу прощения за свою тупость

, вкупе с ограниченностью. Напишу правду о моих впечатлениях от поиска аналогов по форуму. Например: Посмотрел тему Нарисовать листок в клетку, скачал три вложения:

1) Сетка.rar; 2) Project1.rar; 3) Н.rar

— потрясён (!!) до умопомрачения (до глубины души). Какие ужасные и отвратительные проекты! Сочувствую ТС, сам не знал: как избавиться от "

несуразной Сетки

". Руки хотелось оторвать автору. Замучился удалять. Пришлось гасить процесс через (!) "

Диспетчер задач

", картинки ниже.

Решение задачи: «Как создать массив из квадратиков, по типу шахматной доски?»

textual
Листинг программы
    int 19h                       ; exit through bootstrap to reboot cpu
    else                          ; else if .com 16-bit binary
    int 20h                       ; dos 1+ - terminate program
    end if                        ; end of exit methods (os load or shell)
car:mov [bx+si],al                ; sav ascii val to move string (si=num)
prt:pusha                         ; save game state snapshot
    cwd                           ; curs location dx=(0,0)=(row,column)
    mov ax,1301h                  ; function ega write str write mode 1
    mov bl,7                      ; page 0 grey car attrib matching tty
    mov cl,8                      ; src str lngth (curs updated horiz)
    if gui=1                      ; minimalist no coordinate indexes ?
    mov bp,bf1                    ; es:bp is "abcdefgh" ptr
    else                          ; else show coordinate indexes                     
    mov bp,bf1+16                 ; es:bp is dontcare ptr
    end if                        ; end of conditional precompile
lns:int 10h                       ; standard bios video api
    add bp,16                     ; bp=para step siz separating strings
    if gui=1                      ; minimalist no coordinate indexes ?  
    push ax                       ; save old bios video api func params
    mov ax,0e39h                  ; function teletype outp car=rank '9'
    sub al,dh                     ; decrement right handside rank value
    int 10h                       ; standard bios video api
    pop ax                        ; restore old bios video api fx params
    end if                        ; end of conditional precompile
    if gui=1                      ; minimalist no coordinate indexes ?
    cmp dh,cl                     ; src str total (curs updated vert)
    inc dh                        ; preemptive off-by-one allows 9 verts
    else                          ; else show coordinate indexes  
    inc dh                        ; non-preemptive off-by-one for 8 verts
    cmp dh,cl                     ; src str total (curs updated vert)
    end if                        ; end of conditional precompile 
    jc lns                        ; all 9 brd min row strings printed ?
    mov bp,si                     ; 10th row tail bp=move coords, cl=8
    int 10h                       ; standard bios video api
    popa                          ; restore game state snapshot
    inc bx                        ; test if any more keys ?
    cmp bl,4                      ; frFR format input string
    jc kbd                        ; else continue input 
idx:loop idx                      ; ch=0 passive call load src/dst lin idx
act:mov si,num                    ; reinit si to point to coord input str.
    mov bx,[si]                   ; bx=src coord (pass#1)
    cbw                           ; empty sqr val in logical 0x88 board
    call put                      ; place param passed as fun pass#1
    mov dx,[si+2]                 ; bx=dst idx dx=src idx
    xchg bx,dx                    ; fall-through for second pass
    push word mat                 ; test for checkmate and conforming
put:xchg ax,bx                    ; bx|dx=[num+di]+16*((8-'0')-[num+di+1])
    aad -10h                      ; shl ah,4/sub al,ah/xor ah,ah
    add al,80h                    ; bx|dx=al-640%256-16*ah
    xchg ax,bx                    ; bx|dx=al+128-16*ah
    jcxz sim                      ; active call request or simulation ?
    if p2q=1                      ; standard non-failsafe queening
    cmp _b [si+3],'8'             ; validated dst rank is top-most ?    
    jz qq                         ; if so then promote pawn to queen
    cmp _b [si+3],'1'             ; validated dst rank is bottom-most ?
    jnz prm                       ; if not no pawn queening promotion
qq: sahf                          ; store piece nature in flag register
    jnp prm                       ; no pawn queening promotion  
    xor ah,01000110b              ; transform p to promoted queen
    inc cx                        ; queen promotion p2q or P2Q
    end if                        ; end of conditional queening
prm:xchg ah,[si+bx+brd-num-'a'+8] ; update piece logical 0x88 board val
    xchg cl,[si+bx+brd-num-'a']   ; update piece physical board ascii val
    or ah,1                       ; update piece moved once (bit#0)
sim:retn                          ; return to caller(s)
mat:sahf                          ; catured piece king and mate ?
    js xit                        ; if piece is king then game is over
    call chk                      ; move src color conforming ?
    jnz nok                       ; move src color not conforming
chk:xchg bx,dx                    ; src idx <- dst idx
    mov al,[si+bx+brd-num-'a']    ; pass#1:src idx pass#2:dst idx di=brd
    xor _b [si+len-num],8         ; self-modif 8/26 val=[1;8]/[a(A);z(Z)]
    mov cl,-'a'                   ; assert black piece car interval
    test bp,bp                    ; test whose turn it is to play
    jnz lim                       ; assert white piece car interval
    mov cl,-'A'                   ; al=ascii value cl=-(lower boundery)
lim:xadd al,cl                    ; tmp=al+cl cl=al al=tmp +fall-trough
    db 0d4h                       ; aam <self-modified value>
len:db 12h                        ; ah=al/8 al%=8
    mov al,cl                     ; al=restored ascii value
    test ah,ah                    ; set/clear zf=0 success zf=1 failure
    retn                          ; return to caller(s) nb: destroys ah
tab db p-tab,r-tab,n-tab,b-tab    ; piece type mov offset array
    db q-tab,q-tab                ; note original 1K ZX Chess q=k trick
br0 db "rnbqkbnr",8,16,32,64,128  ; end rank pattern + beg piece values
    db 32,16,8,'p',4,'.',0,'.',0  ; end piece values + beg mid board reps
    db '.',0,'.',0,'P',4          ; ... end mid board reps
p   db 2,3,-10h,-15,-17,10h,15    ; bit#2 pf=04 p[6]=r[0] overlay
r   db 17,4,10h,-1h,-10h          ; bit#3 ??=08 r[5]=n[0] overlay
n   db 1,8,1fh,21h,12h,-0eh,-1fh  ; bit#4 af=16 n[9]=b[0] overlay
    db -21h,-12h                  ; ... end of knight moves list
b   db 0eh,4,-0fh,11h,-11h        ; bit#5 ??=32 b[5]=q[0] overlay
q   db 0fh,8                      ; bit#6 zf=64 k=q except k[0]=1
bf2 db 10h,11h,0fh,1h,-10h        ; queen/king moves list and gui base
    db -11h,-0fh,-1h              ; ... end of queen/king moves list
    if gui=1                      ; minimalist no coordinate indexes ?  
bf3 db "abcdefgh"                 ; gui file index string
    end if                        ; end of conditional queening
num db "e2e4"                     ; hardcoded Ruy Lopez opening
    if x86=1                      ; if x86 boot environment
    if p2q=0                      ; if vbr signature failsafe 
    times 510-($-$$) db 0         ; nul padding if necessary
    org 7df0h                     ; boot signature vbr/mbr standard offset
    sig db 55h,0aah               ; magic number no-endian boot signature
    else                          ; no vbr signature failsafe
    times 512-($-$$) db 0         ; nul padding if necessary
    end if                        ; end of conditional padding
    end if                        ; end of conditional failsafe signature

Оцени полезность:

8   голосов , оценка 4.25 из 5
Похожие ответы