Postingan

Project #09 ( Membuat Bingkai )

#include <conio.h> #include <dos.h> #include <stdio.h> #include <stdlib.h> #define VIDEO_INT 0x10 #define UCHAR unsigned char void setMode(UCHAR mode); void getCursorPos(UCHAR *y, UCHAR *x); void setCursorPos(UCHAR y, UCHAR x); void writeChar(UCHAR letter, UCHAR attr); void writeString(UCHAR *str, UCHAR attr); int main(void) { UCHAR baris, kolom; UCHAR pilih; setMode(3); setCursorPos(4, 4); writeChar(213, 0x17); setCursorPos(4, 74); writeChar(184, 0x17); setCursorPos(20, 4); writeChar(192, 0x17); setCursorPos(20, 74); writeChar(217, 0x17); for (baris = 5; baris < 20; baris++) { setCursorPos(baris, 4); writeChar(179, 0x17); setCursorPos(baris, 74); writeChar(179, 0x17); } for (kolom = 5; kolom < 74; kolom++) { setCursorPos(4, kolom); writeChar(205, 0x17); setCursorPos(20, kolom); writeChar(196, 0x17); } setCursorPos(4, 5); writeChar(181, 0x17); setCursorPos(4, 6); writeString(&qu

Project #08 ( Membaca Karakter pada Posisi Kursor )

#include <conio.h> #include <dos.h> #include <stdio.h> #include <stdlib.h> #define VIDEO_INT 0x10 // Nomor interupsi video #define UCHAR unsigned char // Tipe data UCHAR UCHAR getCharAttr(UCHAR *attr); int main(void) { UCHAR huruf, warna; clrscr(); // Bersihkan layar gotoxy(10, 5); textcolor(15); // Warna karakter textbackground(5); // Warna dasar karakter cprintf(" Latihan C++ "); // Cetak string gotoxy(13, 5); // Pindah posisi kursor huruf = getCharAttr(&warna); // Baca nilai karakter // dan atributnya gotoxy(1, 7); printf("Karakter pada baris 5 kolom 13: %c\n", huruf); printf("Warna\\atribut dari karakter : %#x\n", warna); getch(); return EXIT_SUCCESS; } UCHAR getCharAttr(UCHAR *attr) // Fungsi untuk membaca { // karakter dan atributnya union REGS in, out; // pada posisi kursor in.h.ah = 0x08; // AH = 8 heksadesimal in.h.bh = 0x00; // BH = 0, halaman layar

Project #07 ( Menampilkan Karakter dan Memindahkan Posisi Kursor )

#include <conio.h> #include <dos.h> #include <stdlib.h> #define VIDEO_INT 0x10 #define UCHAR unsigned char void getCursorPos(UCHAR *y, UCHAR *x); void setCursorPos(UCHAR y, UCHAR x); void writeChar(UCHAR letter, UCHAR attr); void writeString(UCHAR *str, UCHAR attr); int main(void) { UCHAR baris, kolom; getCursorPos(&baris, &kolom); // Baca posisi kursor writeChar('>', 0x1f); // Cetak karakter > setCursorPos(baris, ++kolom); // Pindahkan kursor writeString(” Mencetak String “, 0x4f); getCursorPos(&baris, &kolom); setCursorPos(baris, ++kolom); writeChar('<', 0x1f); // Cetak karakter < setCursorPos(baris, ++kolom); // Pindahkan kursor getch(); return EXIT_SUCCESS; } void getCursorPos(UCHAR *y, UCHAR *x) // Baca posisi { // kursor UCHAR row, col; asm mov ah, 0x03; // Register AH = 3 heksadesimal asm mov bh, 0x00; // Register BH = 0 heksadesimal asm int VI

Project #06 ( Menampilkan Karakter dan Memindahkan Posisi Kursor )

#include <conio.h> #include <dos.h> #include <stdlib.h> #define VIDEO_INT 0x10 #define UCHAR unsigned char void getCursorPos(UCHAR *y, UCHAR *x); void setCursorPos(UCHAR y, UCHAR x); void writeChar(UCHAR letter, UCHAR attr); int main(void) { UCHAR baris, kolom; getCursorPos(&baris, &kolom); // Baca posisi kursur writeChar('A', 0x1f); // Cetak huruf A setCursorPos(baris, ++kolom); // Pindahkan kursor writeChar('Z', 0x1f); // Cetak huruf Z setCursorPos(baris, ++kolom); // Pindahkan kursor getch(); return EXIT_SUCCESS; } void getCursorPos(UCHAR *y, UCHAR *x) // Baca posisi { // kursor UCHAR row, col; asm mov ah, 0x03; // Register AH = 3 heksadesimal asm mov bh, 0x00; // Register BH = 0 heksadesimal asm int VIDEO_INT; // Lakukan interupsi asm mov row, dh; // Salin register DH ke row asm mov col, dl; // Salin register DL ke col *y = row; *x = col; // Salin row ke y, col ke x

Project #05 ( Memanggil Interupsi BIOS Untuk Operasi Layar Pada Modus Teks )

#include <conio.h> #include <dos.h> #include <stdio.h> #include <stdlib.h> #define VIDEO_INT 0x10 void getMode(union REGS *reg); int main(void) { union REGS layar; getMode(&layar); printf("Informasi Layar Monitor\n"); printf("Banyak kolom\t\t: %d\n", layar.h.ah); printf("Nomor mode\t\t: %0x\n", layar.h.al); printf("Halaman tampilan\t: %d\n", layar.h.bh); getch(); return EXIT_SUCCESS; } void getMode(union REGS *reg) { union REGS *in; in->h.ah = 0x0f; int86(VIDEO_INT, in, reg); return; }

Project #04 ( Memanggil Interupsi BIOS Untuk Operasi Layar Pada Modus Teks )

#include <conio.h> #include <dos.h> #include <stdio.h> #include <stdlib.h> #define VIDEO_INT 0x10 // Nomor interupsi 10h #define UCHAR unsigned char void setMode(UCHAR mode); // Deklarasi fungsi untuk // mengubah mode video int main(void) { printf("Tekan ENTER untuk mengubah mode...\n"); getch(); setMode(0x01); // Ubah mode video printf("Mode 01 heksadesimal.\n"); // Informasi printf("Tekan ENTER kembali ke mode normal..."); getch(); setMode(0x03); // Kembali ke mode normal printf("Mode normal\n"); getch(); return EXIT_SUCCESS; } void setMode(UCHAR mode) { asm mov ah, 0x00; // Register AH = 0 asm mov al, mode; // Register AL = mode asm or al, 0x80; // OR-kan dengan 80 heksadesimal asm int VIDEO_INT; // Lakukan interupsi return; }

Project #03 ( Memanggil Interupsi BIOS Untuk Operasi Layar Pada Modus Teks )

#include <conio.h> #include <dos.h> #include <stdio.h> #include <stdlib.h> #define VIDEO_INT 0x10 // Nomor interupsi 10h #define UCHAR unsigned char void setMode(UCHAR mode); // Deklarasi fungsi untuk // mengubah mode video int main(void) { printf("Tekan ENTER untuk mengubah mode...\n"); getch(); setMode(0x01); // Ubah mode video printf("Mode 01 heksadesimal.\n"); // Informasi printf("Tekan ENTER kembali ke mode normal..."); getch(); setMode(0x03); // Kembali ke mode normal printf("Mode normal\n"); getch(); return EXIT_SUCCESS; } void setMode(UCHAR mode) { union REGS in, out; // Deklarasi variabel in.h.ah = 0x00; // Register AH = 0 in.h.al = mode; // Register AL = mode int86(VIDEO_INT, &in, &out); // Jalankan interupsi return; }